NFC: llcp: Clean raw sockets from nfc_llcp_socket_release
authorSamuel Ortiz <sameo@linux.intel.com>
Thu, 21 Feb 2013 15:33:30 +0000 (16:33 +0100)
committerSamuel Ortiz <sameo@linux.intel.com>
Fri, 8 Mar 2013 16:34:57 +0000 (17:34 +0100)
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
net/nfc/llcp/llcp.c

index 77e1d97b3996e87ccb8547975f4f48454a6010ee..8a35423ead54628985a47857630c60cccc064dfe 100644 (file)
@@ -133,6 +133,35 @@ static void nfc_llcp_socket_release(struct nfc_llcp_local *local, bool listen)
        }
 
        write_unlock(&local->sockets.lock);
+
+       /*
+        * If we want to keep the listening sockets alive,
+        * we don't touch the RAW ones.
+        */
+       if (listen == true)
+               return;
+
+       write_lock(&local->raw_sockets.lock);
+
+       sk_for_each_safe(sk, tmp, &local->raw_sockets.head) {
+               llcp_sock = nfc_llcp_sock(sk);
+
+               bh_lock_sock(sk);
+
+               nfc_llcp_socket_purge(llcp_sock);
+
+               sk->sk_state = LLCP_CLOSED;
+
+               sk->sk_state_change(sk);
+
+               bh_unlock_sock(sk);
+
+               sock_orphan(sk);
+
+               sk_del_node_init(sk);
+       }
+
+       write_unlock(&local->raw_sockets.lock);
 }
 
 struct nfc_llcp_local *nfc_llcp_local_get(struct nfc_llcp_local *local)