From patchwork Fri Nov 13 16:15:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kai-Heng Feng X-Patchwork-Id: 1399918 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CXk9Q4hDLz9sVV; Sat, 14 Nov 2020 03:16:10 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1kdbk7-0004UY-9D; Fri, 13 Nov 2020 16:16:07 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1kdbk6-0004UI-6m for kernel-team@lists.ubuntu.com; Fri, 13 Nov 2020 16:16:06 +0000 Received: from 61-220-137-34.hinet-ip.hinet.net ([61.220.137.34] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1kdbk5-00015J-DN for kernel-team@lists.ubuntu.com; Fri, 13 Nov 2020 16:16:06 +0000 From: Kai-Heng Feng To: kernel-team@lists.ubuntu.com Subject: [PATCH 2/2] Bluetooth: btrtl: fix incorrect skb allocation failure check Date: Sat, 14 Nov 2020 00:15:52 +0800 Message-Id: <20201113161552.988399-3-kai.heng.feng@canonical.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201113161552.988399-1-kai.heng.feng@canonical.com> References: <20201113161552.988399-1-kai.heng.feng@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Colin Ian King BugLink: https://bugs.launchpad.net/bugs/1904221 Currently the check for a failed bt_skb_alloc allocation is incorrectly checking using IS_ERR and this can lead to a null pointer dereference. Fix this by checking for a null pointer return using the !skb idiom. Addresses-Coverity: ("Dereference null return") Fixes: 1996d9cad6ad ("Bluetooth: btrtl: Ask 8821C to drop old firmware") Signed-off-by: Colin Ian King Signed-off-by: Marcel Holtmann (cherry picked from commit f5e8e215869eed6163d5fdd309f0e674a0f23df6 linux-next) Signed-off-by: Kai-Heng Feng --- drivers/bluetooth/btrtl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/bluetooth/btrtl.c b/drivers/bluetooth/btrtl.c index 37e24bbb2eb4..35fb96dae337 100644 --- a/drivers/bluetooth/btrtl.c +++ b/drivers/bluetooth/btrtl.c @@ -598,7 +598,7 @@ struct btrtl_device_info *btrtl_initialize(struct hci_dev *hdev, cmd[1] = opcode >> 8; skb = bt_skb_alloc(sizeof(cmd), GFP_KERNEL); - if (IS_ERR(skb)) + if (!skb) goto out_free; skb_put_data(skb, cmd, sizeof(cmd));