From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 904D5C001E0 for ; Mon, 23 Oct 2023 11:31:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234073AbjJWLbL (ORCPT ); Mon, 23 Oct 2023 07:31:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234078AbjJWLbK (ORCPT ); Mon, 23 Oct 2023 07:31:10 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9DB35C1 for ; Mon, 23 Oct 2023 04:31:08 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CC949C433C8; Mon, 23 Oct 2023 11:31:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1698060668; bh=FEPf54/WqUWHFhhl4WqKO9CvxEKOgjvf7hYTLT2Mzv4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ri6ZqQylN4gviJwC9LxZ66mTYAO/qUB+zsfWps2Y/9QIt/bFjkPJmyum9tXD+UD9x BLNNikdnroyMzhsuAJn+p2K8hRBT0uGettmgrRHbH4eZT1oQ0pKAgIbReJu7Z4fu9c KtBidqLYlB6OS3t0NY+vxhQJCi2xn8H+4MSuAIj0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, =?UTF-8?q?=E9=BB=84=E6=80=9D=E8=81=AA?= , Krzysztof Kozlowski , Simon Horman , Jakub Kicinski Subject: [PATCH 5.4 053/123] nfc: nci: fix possible NULL pointer dereference in send_acknowledge() Date: Mon, 23 Oct 2023 12:56:51 +0200 Message-ID: <20231023104819.475918848@linuxfoundation.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231023104817.691299567@linuxfoundation.org> References: <20231023104817.691299567@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 5.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Krzysztof Kozlowski commit 7937609cd387246aed994e81aa4fa951358fba41 upstream. 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 Signed-off-by: Greg Kroah-Hartman --- net/nfc/nci/spi.c | 2 ++ 1 file changed, 2 insertions(+) --- a/net/nfc/nci/spi.c +++ b/net/nfc/nci/spi.c @@ -150,6 +150,8 @@ static int send_acknowledge(struct nci_s 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);