diff options
| author | Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> | 2023-10-13 20:41:29 +0200 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2023-10-25 11:13:31 +0200 |
| commit | 2b2edf089df3a69f0072c6e71563394c5a94e62e (patch) | |
| tree | 3d5a3dde2e69078f879baedff531ec485e7a9b1f /net | |
| parent | a44158aae9f94e575c149113bab09de452ee4e98 (diff) | |
| download | linux-2b2edf089df3a69f0072c6e71563394c5a94e62e.tar.gz linux-2b2edf089df3a69f0072c6e71563394c5a94e62e.tar.bz2 linux-2b2edf089df3a69f0072c6e71563394c5a94e62e.zip | |
nfc: nci: fix possible NULL pointer dereference in send_acknowledge()
commit 7937609cd387246aed994e81aa4fa951358fba41 upstream.
Handle memory allocation failure from nci_skb_alloc() (calling
alloc_skb()) to avoid possible NULL pointer dereference.
Reported-by: 黄思聪 <huangsicong@iie.ac.cn>
Fixes: 391d8a2da787 ("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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'net')
| -rw-r--r-- | net/nfc/nci/spi.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/net/nfc/nci/spi.c b/net/nfc/nci/spi.c index 452f4c16b7a9..d2de7fc226f0 100644 --- a/net/nfc/nci/spi.c +++ b/net/nfc/nci/spi.c @@ -163,6 +163,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); |
