Skip to content

Commit 7937609

Browse files
krzkkuba-moo
authored andcommitted
nfc: nci: fix possible NULL pointer dereference in send_acknowledge()
Handle memory allocation failure from nci_skb_alloc() (calling alloc_skb()) to avoid possible NULL pointer dereference. Reported-by: 黄思聪 <[email protected]> Fixes: 391d8a2 ("NFC: Add NCI over SPI receive") Cc: <[email protected]> Signed-off-by: Krzysztof Kozlowski <[email protected]> Reviewed-by: Simon Horman <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 503930f commit 7937609

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

net/nfc/nci/spi.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,8 @@ static int send_acknowledge(struct nci_spi *nspi, u8 acknowledge)
151151
int ret;
152152

153153
skb = nci_skb_alloc(nspi->ndev, 0, GFP_KERNEL);
154+
if (!skb)
155+
return -ENOMEM;
154156

155157
/* add the NCI SPI header to the start of the buffer */
156158
hdr = skb_push(skb, NCI_SPI_HDR_LEN);

0 commit comments

Comments
 (0)