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 EFED1C001E0 for ; Mon, 23 Oct 2023 11:00:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232855AbjJWLAI (ORCPT ); Mon, 23 Oct 2023 07:00:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232598AbjJWLAH (ORCPT ); Mon, 23 Oct 2023 07:00:07 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 00EEC10DD for ; Mon, 23 Oct 2023 04:00:03 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3A686C43391; Mon, 23 Oct 2023 11:00:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1698058803; bh=DbrcvbD9K39Zf+6trxOpxqtx/fmcfO+UBbrRaE4PczA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ith9Lkz1G8SlIjuzPkV/Ni5KTfAFZ1GD2ky2ghMBa/TLrAD68JLdRoZt+kMAP5zmv 3ExMqOr1e1R7xYpdgqvvx7be60yqlf9h9UOcJVqnwCSs8tz3HNTNp9zU7Bc56vACW5 noLna6QjVyQWpKJee7eDwYhpk23fEvIeyk2V/Jx4= 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 4.14 32/66] nfc: nci: fix possible NULL pointer dereference in send_acknowledge() Date: Mon, 23 Oct 2023 12:56:22 +0200 Message-ID: <20231023104812.032154129@linuxfoundation.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231023104810.781270702@linuxfoundation.org> References: <20231023104810.781270702@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 4.14-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 @@ -163,6 +163,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);