Re: [PATCH net 2/2] nfc: st21nfca: Free the ATR_REQ skb after sending it
From: Simon Horman
Date: Wed Nov 18 2026 - 13:17:06 EST
On Thu, Nov 12, 2026 at 10:04:49AM +0000, Suyuan Wang via B4 Relay wrote:
> From: Suyuan Wang <stevewong@xxxxxxxxxxx>
>
> st21nfca_im_send_atr_req() allocates an skb for the ATR_REQ, passes
> its data to the HCI layer and then forgets about it:
>
> return nfc_hci_send_cmd_async(hdev, ST21NFCA_RF_READER_F_GATE,
> ST21NFCA_WR_XCHG_DATA, skb->data,
> skb->len, info->async_cb, info);
>
> nfc_hci_send_cmd_async() copies the payload into its own fragments, so
> the skb is still ours to free. As it is, one skb leaks on every ATR_REQ
> sent in initiator mode, whether or not the command was queued.
>
> Free it right after the call, on success and on error, as
> st21nfca_tx_work() does for the same call.
>
> Found with a static analysis tool and checked by hand.
>
> Fixes: 1892bf844ea0 ("NFC: st21nfca: Adding P2P support to st21nfca in Initiator & Target mode")
> Cc: stable@xxxxxxxxxxxxxxx
> Co-developed-by: Kaixuan Li <kaixuan.li@xxxxxxxxxx>
> Signed-off-by: Kaixuan Li <kaixuan.li@xxxxxxxxxx>
> Signed-off-by: Suyuan Wang <stevewong@xxxxxxxxxxx>
> ---
> Compile tested only, I don't have ST21NFCA hardware.
Reviewed-by: Simon Horman <horms@xxxxxxxxxx>