* [PATCH] nfc: llcp: fix sdreq TLV list leak on parse/alloc/send failure
@ 2026-09-14 12:11 Cong Nguyen
2026-09-17 8:33 ` Simon Horman
0 siblings, 1 reply; 2+ messages in thread
From: Cong Nguyen @ 2026-09-14 12:11 UTC (permalink / raw)
To: David Heidelberg
Cc: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, oe-linux-nfc, netdev, linux-kernel
nfc_genl_llc_sdreq() builds a list of TLV nodes while walking nested
netlink attrs, but 3 error paths (nested-attr parse failure, TLV alloc
ENOMEM, nfc_llcp_send_snl_sdreq() failure) all skip freeing what was
already queued.
Route them through a new free_list label, mirroring the SDRES path in
the same file which already does this. Harmless on the success path
too -- send_snl_sdreq() drains the list as it moves nodes, so it's
already empty by the time free_list runs.
Fixes: d9b8d8e19b07 ("NFC: llcp: Service Name Lookup netlink interface")
Assisted-by: Claude:claude-opus-4
Signed-off-by: Cong Nguyen <congnt264@gmail.com>
---
net/nfc/netlink.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/net/nfc/netlink.c b/net/nfc/netlink.c
index 0c58824cb150..224bdfa2dd0d 100644
--- a/net/nfc/netlink.c
+++ b/net/nfc/netlink.c
@@ -1181,7 +1181,7 @@ static int nfc_genl_llc_sdreq(struct sk_buff *skb, struct genl_info *info)
if (rc != 0) {
rc = -EINVAL;
- goto put_local;
+ goto free_list;
}
if (!sdp_attrs[NFC_SDP_ATTR_URI])
@@ -1200,7 +1200,7 @@ static int nfc_genl_llc_sdreq(struct sk_buff *skb, struct genl_info *info)
sdreq = nfc_llcp_build_sdreq_tlv(tid, uri, uri_len);
if (sdreq == NULL) {
rc = -ENOMEM;
- goto put_local;
+ goto free_list;
}
tlvs_len += sdreq->tlv_len;
@@ -1215,6 +1215,9 @@ static int nfc_genl_llc_sdreq(struct sk_buff *skb, struct genl_info *info)
rc = nfc_llcp_send_snl_sdreq(local, &sdreq_list, tlvs_len);
+free_list:
+ nfc_llcp_free_sdp_tlv_list(&sdreq_list);
+
put_local:
nfc_llcp_local_put(local);
--
2.25.1
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] nfc: llcp: fix sdreq TLV list leak on parse/alloc/send failure
2026-09-14 12:11 [PATCH] nfc: llcp: fix sdreq TLV list leak on parse/alloc/send failure Cong Nguyen
@ 2026-09-17 8:33 ` Simon Horman
0 siblings, 0 replies; 2+ messages in thread
From: Simon Horman @ 2026-09-17 8:33 UTC (permalink / raw)
To: Cong Nguyen
Cc: David Heidelberg, David S . Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, oe-linux-nfc, netdev, linux-kernel
On Mon, Sep 14, 2026 at 07:11:29PM +0700, Cong Nguyen wrote:
> nfc_genl_llc_sdreq() builds a list of TLV nodes while walking nested
> netlink attrs, but 3 error paths (nested-attr parse failure, TLV alloc
> ENOMEM, nfc_llcp_send_snl_sdreq() failure) all skip freeing what was
> already queued.
>
> Route them through a new free_list label, mirroring the SDRES path in
> the same file which already does this. Harmless on the success path
> too -- send_snl_sdreq() drains the list as it moves nodes, so it's
> already empty by the time free_list runs.
>
> Fixes: d9b8d8e19b07 ("NFC: llcp: Service Name Lookup netlink interface")
> Assisted-by: Claude:claude-opus-4
> Signed-off-by: Cong Nguyen <congnt264@gmail.com>
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-09-17 8:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-14 12:11 [PATCH] nfc: llcp: fix sdreq TLV list leak on parse/alloc/send failure Cong Nguyen
2026-09-17 8:33 ` Simon Horman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®