Skip to content

Commit

Permalink
nfc: llcp: protect nfc_llcp_sock_unlink() calls
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
krzk authored and davem330 committed Mar 3, 2022
1 parent a736491 commit a06b804
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions net/nfc/llcp_sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);
Expand Down

0 comments on commit a06b804

Please sign in to comment.