From patchwork Mon Mar 13 09:03:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiasheng Jiang X-Patchwork-Id: 13172093 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 417F1C6FD19 for ; Mon, 13 Mar 2023 09:11:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230238AbjCMJLo (ORCPT ); Mon, 13 Mar 2023 05:11:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230229AbjCMJLW (ORCPT ); Mon, 13 Mar 2023 05:11:22 -0400 X-Greylist: delayed 401 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Mon, 13 Mar 2023 02:10:56 PDT Received: from cstnet.cn (smtp81.cstnet.cn [159.226.251.81]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6BB2B6EB8; Mon, 13 Mar 2023 02:10:55 -0700 (PDT) Received: from localhost.localdomain (unknown [124.16.138.125]) by APP-03 (Coremail) with SMTP id rQCowACXnx_95g5kIV2jDg--.57156S2; Mon, 13 Mar 2023 17:03:57 +0800 (CST) From: Jiasheng Jiang To: marcel@holtmann.org, johan.hedberg@gmail.com, luiz.dentz@gmail.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jiasheng Jiang Subject: [PATCH] Bluetooth: 6LoWPAN: Add missing check for skb_clone Date: Mon, 13 Mar 2023 17:03:46 +0800 Message-Id: <20230313090346.48778-1-jiasheng@iscas.ac.cn> X-Mailer: git-send-email 2.25.1 MIME-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aVFxhVjvj DU0xZFpf9x0JUDkucUUUUU= 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 4eb1b3ced0d2..bf42a0b03e20 100644 --- a/net/bluetooth/6lowpan.c +++ b/net/bluetooth/6lowpan.c @@ -477,6 +477,10 @@ static int send_mcast_pkt(struct sk_buff *skb, struct net_device *netdev) int ret; local_skb = skb_clone(skb, GFP_ATOMIC); + if (!local_skb) { + rcu_read_unlock(); + return -ENOMEM; + } BT_DBG("xmit %s to %pMR type %u IP %pI6c chan %p", netdev->name,