]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-client.git/commit
nfc: pn533: allocate rx skb before consuming bytes
authorPengpeng Hou <pengpeng@iscas.ac.cn>
Sun, 5 Apr 2026 00:40:00 +0000 (08:40 +0800)
committerPaolo Abeni <pabeni@redhat.com>
Thu, 9 Apr 2026 11:54:37 +0000 (13:54 +0200)
commitc71ba669b570c7b3f86ec875be222ea11dacb352
tree8c40916d8c87f40f5e8ff38ddfe03dd27a3f857a
parentebe560ea5f54134279356703e73b7f867c89db13
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: c656aa4c27b1 ("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>
drivers/nfc/pn533/uart.c