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 X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 312F3C07E9B for ; Sun, 4 Jul 2021 17:33:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0F0D1613BD for ; Sun, 4 Jul 2021 17:33:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229774AbhGDRfu convert rfc822-to-8bit (ORCPT ); Sun, 4 Jul 2021 13:35:50 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:56605 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229575AbhGDRft (ORCPT ); Sun, 4 Jul 2021 13:35:49 -0400 Received: from smtpclient.apple (p5b3d2eb8.dip0.t-ipconnect.de [91.61.46.184]) by mail.holtmann.org (Postfix) with ESMTPSA id 81438CECCC; Sun, 4 Jul 2021 19:33:11 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.100.0.2.22\)) Subject: Re: [PATCH] bluetooth/virtio_bt: Fix dereference null return value From: Marcel Holtmann In-Reply-To: <20210704145504.24756-1-john.wood@gmx.com> Date: Sun, 4 Jul 2021 19:33:10 +0200 Cc: Johan Hedberg , Luiz Augusto von Dentz , stable , Bluetooth Kernel Mailing List , linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8BIT Message-Id: References: <20210704145504.24756-1-john.wood@gmx.com> To: John Wood X-Mailer: Apple Mail (2.3654.100.0.2.22) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi John, > The alloc_skb function returns NULL on error. So, test this case and > avoid a NULL dereference (skb->data). > > Addresses-Coverity-ID: 1484718 ("Dereference null return value") > Fixes: afd2daa26c7ab ("Bluetooth: Add support for virtio transport driver") > Signed-off-by: John Wood > --- > drivers/bluetooth/virtio_bt.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/bluetooth/virtio_bt.c b/drivers/bluetooth/virtio_bt.c > index c804db7e90f8..5f82574236c0 100644 > --- a/drivers/bluetooth/virtio_bt.c > +++ b/drivers/bluetooth/virtio_bt.c > @@ -34,6 +34,8 @@ static int virtbt_add_inbuf(struct virtio_bluetooth *vbt) > int err; > > skb = alloc_skb(1000, GFP_KERNEL); > + if (!skb) > + return -ENOMEM; > sg_init_one(sg, skb->data, 1000); this is already fixed. Author: Colin Ian King Date: Fri Apr 9 17:53:14 2021 +0100 Bluetooth: virtio_bt: add missing null pointer check on alloc_skb call return The call to alloc_skb with the GFP_KERNEL flag can return a null sk_buff pointer, so add a null check to avoid any null pointer deference issues. Addresses-Coverity: ("Dereference null return value") Fixes: afd2daa26c7a ("Bluetooth: Add support for virtio transport driver") Signed-off-by: Colin Ian King Signed-off-by: Marcel Holtmann Regards Marcel