From patchwork Mon Mar 20 06:31:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiasheng Jiang X-Patchwork-Id: 665283 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 2D4A2C76196 for ; Mon, 20 Mar 2023 06:32:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229902AbjCTGcW (ORCPT ); Mon, 20 Mar 2023 02:32:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229561AbjCTGcS (ORCPT ); Mon, 20 Mar 2023 02:32:18 -0400 Received: from cstnet.cn (smtp80.cstnet.cn [159.226.251.80]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id AC9A1E045; Sun, 19 Mar 2023 23:32:16 -0700 (PDT) Received: from localhost.localdomain (unknown [124.16.138.125]) by APP-01 (Coremail) with SMTP id qwCowABnb0ve_RdkMBlgEw--.236S3; Mon, 20 Mar 2023 14:32:01 +0800 (CST) From: Jiasheng Jiang To: simon.horman@corigine.com Cc: marcel@holtmann.org, johan.hedberg@gmail.com, luiz.dentz@gmail.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jiasheng Jiang Subject: [PATCH 2/2] Bluetooth: 6LoWPAN: Add missing check for skb_clone Date: Mon, 20 Mar 2023 14:31:56 +0800 Message-Id: <20230320063156.31047-2-jiasheng@iscas.ac.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230320063156.31047-1-jiasheng@iscas.ac.cn> References: <20230320063156.31047-1-jiasheng@isc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IcVC2z280aVAFwI0_Jr0_Gr1lIx AIcVC2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvfC2KfnxnUUI43ZEXa7VUU-BMJUUUUU= = X-Originating-IP: [124.16.138.125] X-CM-SenderInfo: pmld2xxhqjqxpvfd2hldfou0/ Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Add the check for the return value of skb_clone since it may return NULL pointer and cause NULL pointer dereference in send_pkt. Fixes: 18722c247023 ("Bluetooth: Enable 6LoWPAN support for BT LE devices") Signed-off-by: Jiasheng Jiang --- net/bluetooth/6lowpan.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/net/bluetooth/6lowpan.c b/net/bluetooth/6lowpan.c index bd6dbca5747f..3d4ef94405f8 100644 --- a/net/bluetooth/6lowpan.c +++ b/net/bluetooth/6lowpan.c @@ -475,6 +475,10 @@ static int send_mcast_pkt(struct sk_buff *skb, struct net_device *netdev) list_for_each_entry_rcu(pentry, &dev->peers, list) { local_skb = skb_clone(skb, GFP_ATOMIC); + if (!local_skb) { + err = -ENOMEM; + goto out; + } BT_DBG("xmit %s to %pMR type %u IP %pI6c chan %p", netdev->name,