diff options
author | John W. Linville <linville@tuxdriver.com> | 2013-03-15 10:44:36 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2013-03-15 10:44:36 -0400 |
commit | f3a3440063d6b01470507ecde9cf8ed0b033362a (patch) | |
tree | 11376f47f8db09adec4f80056137b07a811f0407 /net | |
parent | aaa0c23cb90141309f5076ba5e3bfbd39544b985 (diff) | |
parent | 9437a248e7cac427c898bdb11bd1ac6844a1ead4 (diff) |
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless into for-davem
Diffstat (limited to 'net')
-rw-r--r-- | net/nfc/llcp/llcp.c | 62 | ||||
-rw-r--r-- | net/nfc/llcp/sock.c | 2 |
2 files changed, 55 insertions, 9 deletions
diff --git a/net/nfc/llcp/llcp.c b/net/nfc/llcp/llcp.c index 7f8266dd14cb..b530afadd76c 100644 --- a/net/nfc/llcp/llcp.c +++ b/net/nfc/llcp/llcp.c | |||
@@ -68,7 +68,8 @@ static void nfc_llcp_socket_purge(struct nfc_llcp_sock *sock) | |||
68 | } | 68 | } |
69 | } | 69 | } |
70 | 70 | ||
71 | static void nfc_llcp_socket_release(struct nfc_llcp_local *local, bool listen) | 71 | static void nfc_llcp_socket_release(struct nfc_llcp_local *local, bool listen, |
72 | int err) | ||
72 | { | 73 | { |
73 | struct sock *sk; | 74 | struct sock *sk; |
74 | struct hlist_node *tmp; | 75 | struct hlist_node *tmp; |
@@ -100,7 +101,10 @@ static void nfc_llcp_socket_release(struct nfc_llcp_local *local, bool listen) | |||
100 | 101 | ||
101 | nfc_llcp_accept_unlink(accept_sk); | 102 | nfc_llcp_accept_unlink(accept_sk); |
102 | 103 | ||
104 | if (err) | ||
105 | accept_sk->sk_err = err; | ||
103 | accept_sk->sk_state = LLCP_CLOSED; | 106 | accept_sk->sk_state = LLCP_CLOSED; |
107 | accept_sk->sk_state_change(sk); | ||
104 | 108 | ||
105 | bh_unlock_sock(accept_sk); | 109 | bh_unlock_sock(accept_sk); |
106 | 110 | ||
@@ -123,7 +127,10 @@ static void nfc_llcp_socket_release(struct nfc_llcp_local *local, bool listen) | |||
123 | continue; | 127 | continue; |
124 | } | 128 | } |
125 | 129 | ||
130 | if (err) | ||
131 | sk->sk_err = err; | ||
126 | sk->sk_state = LLCP_CLOSED; | 132 | sk->sk_state = LLCP_CLOSED; |
133 | sk->sk_state_change(sk); | ||
127 | 134 | ||
128 | bh_unlock_sock(sk); | 135 | bh_unlock_sock(sk); |
129 | 136 | ||
@@ -133,6 +140,36 @@ static void nfc_llcp_socket_release(struct nfc_llcp_local *local, bool listen) | |||
133 | } | 140 | } |
134 | 141 | ||
135 | write_unlock(&local->sockets.lock); | 142 | write_unlock(&local->sockets.lock); |
143 | |||
144 | /* | ||
145 | * If we want to keep the listening sockets alive, | ||
146 | * we don't touch the RAW ones. | ||
147 | */ | ||
148 | if (listen == true) | ||
149 | return; | ||
150 | |||
151 | write_lock(&local->raw_sockets.lock); | ||
152 | |||
153 | sk_for_each_safe(sk, tmp, &local->raw_sockets.head) { | ||
154 | llcp_sock = nfc_llcp_sock(sk); | ||
155 | |||
156 | bh_lock_sock(sk); | ||
157 | |||
158 | nfc_llcp_socket_purge(llcp_sock); | ||
159 | |||
160 | if (err) | ||
161 | sk->sk_err = err; | ||
162 | sk->sk_state = LLCP_CLOSED; | ||
163 | sk->sk_state_change(sk); | ||
164 | |||
165 | bh_unlock_sock(sk); | ||
166 | |||
167 | sock_orphan(sk); | ||
168 | |||
169 | sk_del_node_init(sk); | ||
170 | } | ||
171 | |||
172 | write_unlock(&local->raw_sockets.lock); | ||
136 | } | 173 | } |
137 | 174 | ||
138 | struct nfc_llcp_local *nfc_llcp_local_get(struct nfc_llcp_local *local) | 175 | struct nfc_llcp_local *nfc_llcp_local_get(struct nfc_llcp_local *local) |
@@ -142,20 +179,25 @@ struct nfc_llcp_local *nfc_llcp_local_get(struct nfc_llcp_local *local) | |||
142 | return local; | 179 | return local; |
143 | } | 180 | } |
144 | 181 | ||
145 | static void local_release(struct kref *ref) | 182 | static void local_cleanup(struct nfc_llcp_local *local, bool listen) |
146 | { | 183 | { |
147 | struct nfc_llcp_local *local; | 184 | nfc_llcp_socket_release(local, listen, ENXIO); |
148 | |||
149 | local = container_of(ref, struct nfc_llcp_local, ref); | ||
150 | |||
151 | list_del(&local->list); | ||
152 | nfc_llcp_socket_release(local, false); | ||
153 | del_timer_sync(&local->link_timer); | 185 | del_timer_sync(&local->link_timer); |
154 | skb_queue_purge(&local->tx_queue); | 186 | skb_queue_purge(&local->tx_queue); |
155 | cancel_work_sync(&local->tx_work); | 187 | cancel_work_sync(&local->tx_work); |
156 | cancel_work_sync(&local->rx_work); | 188 | cancel_work_sync(&local->rx_work); |
157 | cancel_work_sync(&local->timeout_work); | 189 | cancel_work_sync(&local->timeout_work); |
158 | kfree_skb(local->rx_pending); | 190 | kfree_skb(local->rx_pending); |
191 | } | ||
192 | |||
193 | static void local_release(struct kref *ref) | ||
194 | { | ||
195 | struct nfc_llcp_local *local; | ||
196 | |||
197 | local = container_of(ref, struct nfc_llcp_local, ref); | ||
198 | |||
199 | list_del(&local->list); | ||
200 | local_cleanup(local, false); | ||
159 | kfree(local); | 201 | kfree(local); |
160 | } | 202 | } |
161 | 203 | ||
@@ -1348,7 +1390,7 @@ void nfc_llcp_mac_is_down(struct nfc_dev *dev) | |||
1348 | return; | 1390 | return; |
1349 | 1391 | ||
1350 | /* Close and purge all existing sockets */ | 1392 | /* Close and purge all existing sockets */ |
1351 | nfc_llcp_socket_release(local, true); | 1393 | nfc_llcp_socket_release(local, true, 0); |
1352 | } | 1394 | } |
1353 | 1395 | ||
1354 | void nfc_llcp_mac_is_up(struct nfc_dev *dev, u32 target_idx, | 1396 | void nfc_llcp_mac_is_up(struct nfc_dev *dev, u32 target_idx, |
@@ -1427,6 +1469,8 @@ void nfc_llcp_unregister_device(struct nfc_dev *dev) | |||
1427 | return; | 1469 | return; |
1428 | } | 1470 | } |
1429 | 1471 | ||
1472 | local_cleanup(local, false); | ||
1473 | |||
1430 | nfc_llcp_local_put(local); | 1474 | nfc_llcp_local_put(local); |
1431 | } | 1475 | } |
1432 | 1476 | ||
diff --git a/net/nfc/llcp/sock.c b/net/nfc/llcp/sock.c index 5332751943a9..5c7cdf3f2a83 100644 --- a/net/nfc/llcp/sock.c +++ b/net/nfc/llcp/sock.c | |||
@@ -278,6 +278,8 @@ struct sock *nfc_llcp_accept_dequeue(struct sock *parent, | |||
278 | 278 | ||
279 | pr_debug("Returning sk state %d\n", sk->sk_state); | 279 | pr_debug("Returning sk state %d\n", sk->sk_state); |
280 | 280 | ||
281 | sk_acceptq_removed(parent); | ||
282 | |||
281 | return sk; | 283 | return sk; |
282 | } | 284 | } |
283 | 285 | ||