From: Krzysztof Kozlowski Date: Fri, 13 Oct 2023 18:41:29 +0000 (+0200) Subject: nfc: nci: fix possible NULL pointer dereference in send_acknowledge() X-Git-Tag: v6.6.17~3727^2~23 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7937609cd387246aed994e81aa4fa951358fba41;p=platform%2Fkernel%2Flinux-rpi.git 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: 黄思聪 Fixes: 391d8a2da787 ("NFC: Add NCI over SPI receive") Cc: Signed-off-by: Krzysztof Kozlowski Reviewed-by: Simon Horman Link: https://lore.kernel.org/r/20231013184129.18738-1-krzysztof.kozlowski@linaro.org Signed-off-by: Jakub Kicinski --- diff --git a/net/nfc/nci/spi.c b/net/nfc/nci/spi.c index 0935527..b68150c 100644 --- a/net/nfc/nci/spi.c +++ b/net/nfc/nci/spi.c @@ -151,6 +151,8 @@ static int send_acknowledge(struct nci_spi *nspi, u8 acknowledge) int ret; skb = nci_skb_alloc(nspi->ndev, 0, GFP_KERNEL); + if (!skb) + return -ENOMEM; /* add the NCI SPI header to the start of the buffer */ hdr = skb_push(skb, NCI_SPI_HDR_LEN);