nfc_llcp_recv_ui() looks the destination socket up with nfc_llcp_sock_get(), which takes a socket reference. Sockets of every type are linked into local->sockets, so a bound SOCK_STREAM socket can match the lookup. When the socket is not a SOCK_DGRAM one the function returns early without dropping the reference, leaking it for every received UI frame sent to such a socket. Split the check and put the reference on the non-datagram path as well. Fixes: 968272bf0087 ("NFC: Handle LLCP UI frames") Cc: stable@vger.kernel.org Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex Signed-off-by: Wentao Liang --- net/nfc/llcp_core.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/net/nfc/llcp_core.c b/net/nfc/llcp_core.c index 92fd7e29ec8a..92dbba7d285a 100644 --- a/net/nfc/llcp_core.c +++ b/net/nfc/llcp_core.c @@ -917,8 +917,12 @@ static void nfc_llcp_recv_ui(struct nfc_llcp_local *local, /* We're looking for a bound socket, not a client one */ llcp_sock = nfc_llcp_sock_get(local, dsap, LLCP_SAP_SDP); - if (llcp_sock == NULL || llcp_sock->sk.sk_type != SOCK_DGRAM) + if (llcp_sock == NULL) return; + if (llcp_sock->sk.sk_type != SOCK_DGRAM) { + nfc_llcp_sock_put(llcp_sock); + return; + } /* There is no sequence with UI frames */ skb_pull(skb, LLCP_HEADER_SIZE); -- 2.34.1