Skip to content

Commit 17f7ae1

Browse files
Thierry EscandeSamuel Ortiz
authored andcommitted
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 <[email protected]> Signed-off-by: Samuel Ortiz <[email protected]>
1 parent 58e3dd1 commit 17f7ae1

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

net/nfc/llcp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
enum llcp_state {
2121
LLCP_CONNECTED = 1, /* wait_for_packet() wants that */
22+
LLCP_DISCONNECTING,
2223
LLCP_CLOSED,
2324
LLCP_BOUND,
2425
LLCP_LISTEN,

net/nfc/llcp_core.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -730,6 +730,13 @@ static void nfc_llcp_tx_work(struct work_struct *work)
730730
DUMP_PREFIX_OFFSET, 16, 1,
731731
skb->data, skb->len, true);
732732

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+
733740
if (ptype == LLCP_PDU_I)
734741
copy_skb = skb_copy(skb, GFP_ATOMIC);
735742

net/nfc/llcp_sock.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,13 @@ static int llcp_sock_release(struct socket *sock)
626626

627627
release_sock(sk);
628628

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+
629636
if (sock->type == SOCK_RAW)
630637
nfc_llcp_sock_unlink(&local->raw_sockets, sk);
631638
else

0 commit comments

Comments
 (0)