aboutsummaryrefslogtreecommitdiffstats
path: root/net/nfc
diff options
context:
space:
mode:
authorSamuel Ortiz <sameo@linux.intel.com>2012-06-22 08:40:34 -0400
committerJohn W. Linville <linville@tuxdriver.com>2012-07-09 16:42:16 -0400
commit4d22ea1532ba5730b665343e513d813c108c84ff (patch)
treecf8d40fadc183ace285d372965c6416c2329f52e /net/nfc
parentb8e7a06d9cd4c0e778b1d12cef1ef414e0fb6d7e (diff)
NFC: Close listening LLCP sockets when the device is gone
When the MAC link goes down, we should only keep the bound sockets alive. They will be closed by sock_release or when the underlying NFC device is moving away. Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'net/nfc')
-rw-r--r--net/nfc/llcp/llcp.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/net/nfc/llcp/llcp.c b/net/nfc/llcp/llcp.c
index 6812b1e4f025..0c8d25e53ff6 100644
--- a/net/nfc/llcp/llcp.c
+++ b/net/nfc/llcp/llcp.c
@@ -45,7 +45,7 @@ void nfc_llcp_sock_unlink(struct llcp_sock_list *l, struct sock *sk)
45 write_unlock(&l->lock); 45 write_unlock(&l->lock);
46} 46}
47 47
48static void nfc_llcp_socket_release(struct nfc_llcp_local *local) 48static void nfc_llcp_socket_release(struct nfc_llcp_local *local, bool listen)
49{ 49{
50 struct sock *sk; 50 struct sock *sk;
51 struct hlist_node *node, *tmp; 51 struct hlist_node *node, *tmp;
@@ -78,6 +78,11 @@ static void nfc_llcp_socket_release(struct nfc_llcp_local *local)
78 78
79 sock_orphan(accept_sk); 79 sock_orphan(accept_sk);
80 } 80 }
81
82 if (listen == true) {
83 release_sock(sk);
84 continue;
85 }
81 } 86 }
82 87
83 sk->sk_state = LLCP_CLOSED; 88 sk->sk_state = LLCP_CLOSED;
@@ -106,7 +111,7 @@ static void local_release(struct kref *ref)
106 local = container_of(ref, struct nfc_llcp_local, ref); 111 local = container_of(ref, struct nfc_llcp_local, ref);
107 112
108 list_del(&local->list); 113 list_del(&local->list);
109 nfc_llcp_socket_release(local); 114 nfc_llcp_socket_release(local, false);
110 del_timer_sync(&local->link_timer); 115 del_timer_sync(&local->link_timer);
111 skb_queue_purge(&local->tx_queue); 116 skb_queue_purge(&local->tx_queue);
112 destroy_workqueue(local->tx_wq); 117 destroy_workqueue(local->tx_wq);
@@ -991,7 +996,7 @@ void nfc_llcp_mac_is_down(struct nfc_dev *dev)
991 nfc_llcp_clear_sdp(local); 996 nfc_llcp_clear_sdp(local);
992 997
993 /* Close and purge all existing sockets */ 998 /* Close and purge all existing sockets */
994 nfc_llcp_socket_release(local); 999 nfc_llcp_socket_release(local, true);
995} 1000}
996 1001
997void nfc_llcp_mac_is_up(struct nfc_dev *dev, u32 target_idx, 1002void nfc_llcp_mac_is_up(struct nfc_dev *dev, u32 target_idx,