Skip to content

Commit d42449d

Browse files
committed
nfc: digital: free skb on digital_in_send error paths
digital_in_send() takes ownership of the skb passed by the caller (nfc_data_exchange), make sure it's freed on all error paths. Found looking around the real driver for similar bugs to the one just fixed in nci. Fixes: 2c66dae ("NFC Digital: Add NFC-A technology support") Reviewed-by: Joe Damato <joe@dama.to> Link: https://patch.msgid.link/20260303162346.2071888-3-kuba@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 7bd4b0c commit d42449d

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

net/nfc/digital_core.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -707,8 +707,10 @@ static int digital_in_send(struct nfc_dev *nfc_dev, struct nfc_target *target,
707707
int rc;
708708

709709
data_exch = kzalloc_obj(*data_exch);
710-
if (!data_exch)
710+
if (!data_exch) {
711+
kfree_skb(skb);
711712
return -ENOMEM;
713+
}
712714

713715
data_exch->cb = cb;
714716
data_exch->cb_context = cb_context;
@@ -731,8 +733,10 @@ static int digital_in_send(struct nfc_dev *nfc_dev, struct nfc_target *target,
731733
data_exch);
732734

733735
exit:
734-
if (rc)
736+
if (rc) {
737+
kfree_skb(skb);
735738
kfree(data_exch);
739+
}
736740

737741
return rc;
738742
}

0 commit comments

Comments
 (0)