Commit 17f7ae16 authored by Thierry Escande's avatar Thierry Escande Committed by Samuel Ortiz

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: default avatarThierry Escande <thierry.escande@linux.intel.com>
Signed-off-by: default avatarSamuel Ortiz <sameo@linux.intel.com>
parent 58e3dd15
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
enum llcp_state { enum llcp_state {
LLCP_CONNECTED = 1, /* wait_for_packet() wants that */ LLCP_CONNECTED = 1, /* wait_for_packet() wants that */
LLCP_DISCONNECTING,
LLCP_CLOSED, LLCP_CLOSED,
LLCP_BOUND, LLCP_BOUND,
LLCP_LISTEN, LLCP_LISTEN,
......
...@@ -730,6 +730,13 @@ static void nfc_llcp_tx_work(struct work_struct *work) ...@@ -730,6 +730,13 @@ static void nfc_llcp_tx_work(struct work_struct *work)
DUMP_PREFIX_OFFSET, 16, 1, DUMP_PREFIX_OFFSET, 16, 1,
skb->data, skb->len, true); skb->data, skb->len, true);
if (ptype == LLCP_PDU_DISC && sk != NULL &&
sk->sk_state == LLCP_DISCONNECTING) {
nfc_llcp_sock_unlink(&local->sockets, sk);
sock_orphan(sk);
sock_put(sk);
}
if (ptype == LLCP_PDU_I) if (ptype == LLCP_PDU_I)
copy_skb = skb_copy(skb, GFP_ATOMIC); copy_skb = skb_copy(skb, GFP_ATOMIC);
......
...@@ -626,6 +626,13 @@ static int llcp_sock_release(struct socket *sock) ...@@ -626,6 +626,13 @@ static int llcp_sock_release(struct socket *sock)
release_sock(sk); release_sock(sk);
/* Keep this sock alive and therefore do not remove it from the sockets
* list until the DISC PDU has been actually sent. Otherwise we would
* reply with DM PDUs before sending the DISC one.
*/
if (sk->sk_state == LLCP_DISCONNECTING)
return err;
if (sock->type == SOCK_RAW) if (sock->type == SOCK_RAW)
nfc_llcp_sock_unlink(&local->raw_sockets, sk); nfc_llcp_sock_unlink(&local->raw_sockets, sk);
else else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment