aboutsummaryrefslogtreecommitdiffstats
path: root/net/nfc
diff options
context:
space:
mode:
authorThierry Escande <thierry.escande@linux.intel.com>2013-06-04 05:34:51 -0400
committerSamuel Ortiz <sameo@linux.intel.com>2013-06-14 07:45:05 -0400
commit17f7ae16aef1f58bc4af4c7a16b8778a91a30255 (patch)
tree02ee0a69207c231a5bd3939ccee7021cbbaddd65 /net/nfc
parent58e3dd1558f56e95e7077a63340bb33e7aa42946 (diff)
NFC: Keep socket alive until the DISC PDU is actually sent
This patch keeps the socket alive and therefore does not remove it from the sockets list in the local until the DISC PDU has been actually sent. Otherwise we would reply with DM PDUs before sending the DISC one. Signed-off-by: Thierry Escande <thierry.escande@linux.intel.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'net/nfc')
-rw-r--r--net/nfc/llcp.h1
-rw-r--r--net/nfc/llcp_core.c7
-rw-r--r--net/nfc/llcp_sock.c7
3 files changed, 15 insertions, 0 deletions
diff --git a/net/nfc/llcp.h b/net/nfc/llcp.h
index ac16ebe3069d..71f649e5ef49 100644
--- a/net/nfc/llcp.h
+++ b/net/nfc/llcp.h
@@ -19,6 +19,7 @@
19 19
20enum llcp_state { 20enum llcp_state {
21 LLCP_CONNECTED = 1, /* wait_for_packet() wants that */ 21 LLCP_CONNECTED = 1, /* wait_for_packet() wants that */
22 LLCP_DISCONNECTING,
22 LLCP_CLOSED, 23 LLCP_CLOSED,
23 LLCP_BOUND, 24 LLCP_BOUND,
24 LLCP_LISTEN, 25 LLCP_LISTEN,
diff --git a/net/nfc/llcp_core.c b/net/nfc/llcp_core.c
index 158bdbf668cc..1c4c048e0a1b 100644
--- a/net/nfc/llcp_core.c
+++ b/net/nfc/llcp_core.c
@@ -730,6 +730,13 @@ static void nfc_llcp_tx_work(struct work_struct *work)
730 DUMP_PREFIX_OFFSET, 16, 1, 730 DUMP_PREFIX_OFFSET, 16, 1,
731 skb->data, skb->len, true); 731 skb->data, skb->len, true);
732 732
733 if (ptype == LLCP_PDU_DISC && sk != NULL &&
734 sk->sk_state == LLCP_DISCONNECTING) {
735 nfc_llcp_sock_unlink(&local->sockets, sk);
736 sock_orphan(sk);
737 sock_put(sk);
738 }
739
733 if (ptype == LLCP_PDU_I) 740 if (ptype == LLCP_PDU_I)
734 copy_skb = skb_copy(skb, GFP_ATOMIC); 741 copy_skb = skb_copy(skb, GFP_ATOMIC);
735 742
diff --git a/net/nfc/llcp_sock.c b/net/nfc/llcp_sock.c
index 03fd3162cee5..47e7acfc0236 100644
--- a/net/nfc/llcp_sock.c
+++ b/net/nfc/llcp_sock.c
@@ -626,6 +626,13 @@ static int llcp_sock_release(struct socket *sock)
626 626
627 release_sock(sk); 627 release_sock(sk);
628 628
629 /* Keep this sock alive and therefore do not remove it from the sockets
630 * list until the DISC PDU has been actually sent. Otherwise we would
631 * reply with DM PDUs before sending the DISC one.
632 */
633 if (sk->sk_state == LLCP_DISCONNECTING)
634 return err;
635
629 if (sock->type == SOCK_RAW) 636 if (sock->type == SOCK_RAW)
630 nfc_llcp_sock_unlink(&local->raw_sockets, sk); 637 nfc_llcp_sock_unlink(&local->raw_sockets, sk);
631 else 638 else