linux/drivers/nfc
Pengpeng Hou c71ba669b5 nfc: pn533: allocate rx skb before consuming bytes
pn532_receive_buf() reports the number of accepted bytes to the serdev
core. The current code consumes bytes into recv_skb and may already hand
a complete frame to pn533_recv_frame() before allocating a fresh receive
buffer.

If that alloc_skb() fails, the callback returns 0 even though it has
already consumed bytes, and it leaves recv_skb as NULL for the next
receive callback. That breaks the receive_buf() accounting contract and
can also lead to a NULL dereference on the next skb_put_u8().

Allocate the receive skb lazily before consuming the next byte instead.
If allocation fails, return the number of bytes already accepted.

Fixes: c656aa4c27 ("nfc: pn533: add UART phy driver")
Cc: stable@vger.kernel.org
Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
Link: https://patch.msgid.link/20260405094003.3-pn533-v2-pengpeng@iscas.ac.cn
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2026-04-09 13:54:37 +02:00
..
fdp Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2023-06-22 18:40:38 -07:00
microread Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
nfcmrvl Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
nxp-nci NFC: nxp-nci: allow GPIOs to sleep 2026-03-18 17:20:51 -07:00
pn533 nfc: pn533: allocate rx skb before consuming bytes 2026-04-09 13:54:37 +02:00
pn544 Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
s3fwrn5 nfc: s3fwrn5: allocate rx skb before consuming bytes 2026-04-03 15:57:46 -07:00
st-nci treewide, timers: Rename from_timer() to timer_container_of() 2025-06-08 09:07:37 +02:00
st21nfca Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
st95hf nfc: st95hf: drop driver owner assignment 2024-03-29 12:32:51 -07:00
Kconfig
Makefile
mei_phy.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
mei_phy.h NFC: mei_phy: fix kernel-doc warnings 2025-11-17 19:32:32 -08:00
nfcsim.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
port100.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
trf7970a.c NFC: trf7970a: Create device-tree parameter for RX gain reduction 2025-06-27 15:08:57 -07:00
virtual_ncidev.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00