summaryrefslogtreecommitdiff
path: root/net/nfc
diff options
context:
space:
mode:
authorKrzysztof Kozlowski <krzysztof.kozlowski@canonical.com>2022-03-02 22:25:22 +0300
committerDavid S. Miller <davem@davemloft.net>2022-03-03 13:43:37 +0300
commita06b8044169f6d5c3eb34772c13d2c0c1b205352 (patch)
tree43ca493cbf91f9e32e1965fb061b303304e3c936 /net/nfc
parenta736491239f4b434fc76a2ba0c1bdb8eaf9eb792 (diff)
downloadlinux-a06b8044169f6d5c3eb34772c13d2c0c1b205352.tar.xz
nfc: llcp: protect nfc_llcp_sock_unlink() calls
nfc_llcp_sock_link() is called in all paths (bind/connect) as a last action, still protected with lock_sock(). When cleaning up in llcp_sock_release(), call nfc_llcp_sock_unlink() in a mirrored way: earlier and still under the lock_sock(). Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/nfc')
-rw-r--r--net/nfc/llcp_sock.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/net/nfc/llcp_sock.c b/net/nfc/llcp_sock.c
index c9d5c427f035..5c5705f5028b 100644
--- a/net/nfc/llcp_sock.c
+++ b/net/nfc/llcp_sock.c
@@ -631,6 +631,11 @@ static int llcp_sock_release(struct socket *sock)
}
}
+ if (sock->type == SOCK_RAW)
+ nfc_llcp_sock_unlink(&local->raw_sockets, sk);
+ else
+ nfc_llcp_sock_unlink(&local->sockets, sk);
+
if (llcp_sock->reserved_ssap < LLCP_SAP_MAX)
nfc_llcp_put_ssap(llcp_sock->local, llcp_sock->ssap);
@@ -643,11 +648,6 @@ static int llcp_sock_release(struct socket *sock)
if (sk->sk_state == LLCP_DISCONNECTING)
return err;
- if (sock->type == SOCK_RAW)
- nfc_llcp_sock_unlink(&local->raw_sockets, sk);
- else
- nfc_llcp_sock_unlink(&local->sockets, sk);
-
out:
sock_orphan(sk);
sock_put(sk);