mirror of
https://github.com/torvalds/linux.git
synced 2024-12-25 20:32:22 +00:00
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: 黄思聪 <huangsicong@iie.ac.cn>
Fixes: 391d8a2da7
("NFC: Add NCI over SPI receive")
Cc: <stable@vger.kernel.org>
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://lore.kernel.org/r/20231013184129.18738-1-krzysztof.kozlowski@linaro.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
503930f8e1
commit
7937609cd3
@ -151,6 +151,8 @@ static int send_acknowledge(struct nci_spi *nspi, u8 acknowledge)
|
|||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
skb = nci_skb_alloc(nspi->ndev, 0, GFP_KERNEL);
|
skb = nci_skb_alloc(nspi->ndev, 0, GFP_KERNEL);
|
||||||
|
if (!skb)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
/* add the NCI SPI header to the start of the buffer */
|
/* add the NCI SPI header to the start of the buffer */
|
||||||
hdr = skb_push(skb, NCI_SPI_HDR_LEN);
|
hdr = skb_push(skb, NCI_SPI_HDR_LEN);
|
||||||
|
Loading…
Reference in New Issue
Block a user