Received: by 2002:a05:7412:f589:b0:e2:908c:2ebd with SMTP id eh9csp875111rdb; Wed, 1 Nov 2023 05:38:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEW2uhS+lEEXMLbdhRDqJA7HBi3JygiNEQ7jFiwdbGBmPhP+/otzC+amLh5t9Jp1X+nMr2g X-Received: by 2002:a17:902:ec86:b0:1cc:e66:372e with SMTP id x6-20020a170902ec8600b001cc0e66372emr19659606plg.20.1698842289087; Wed, 01 Nov 2023 05:38:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698842289; cv=none; d=google.com; s=arc-20160816; b=AYcAjtT42axYn+9cm3x8dVPH0zl5W8WSmzlA3v3oC8Sxrl66zaExCWlVBqfHN8Jlw0 m43D8zcx2ui07O9WhBZGqWsu4tVRXQzCemkW5aD6kEKxNVjzHoupE6GcdBx3XajNOPQJ 7a4HO1Kd3LaGDtq8bd35xodSeSy8wWQvdXnEAsYA1sVUZHmGG95GiuyKsrGNpeRE37dp y/DydakDfBs5Ap6YNsqC8dQ0whw/7fmUyPra8ebB/ZnPkG9GOrHVLZHMEyByA9EbVvzf Gpwoktyq/bLS6gwZvhSDGT9laKQSgZN/ZC/a0LAnf3lB/keRc87K4p9VPY2XKiBy7Zdf NDKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=pnt8GBLnH1VM5SF7zUH38Q71Vd2TwZX3RIbZDnYhDhY=; fh=ZmWauB5a+fZPwzlAH6Qdc9nUTiaK+a4mTm2pVl4yLtM=; b=djYQqEMOpcUYBqR1fk7MQJwVPWNJ0rmTBveJDHrjp8mxkGHYCGWzAEzw1D+p+3tsxp KlOC/w5qjnWgOO93cHxmk+Dn7DaicP0w3vx1W+GN9j7pq1IOeSCIyY4dragipfPEl9Dx +xxdw/Beb9ZJRkE3SEyaY75+lNTuAjtE0CjKDU3U97WI2WSzTKW3jgeOAbpmCOsxBw8g VcsZlryTEaj+6RMvB8yT7A6xr2909b25GvqRZg7d2/VPKzEPMeVc8slWePuqyA4vifjH fTGs1xlljtgOvz4guIrmVlhu6aE28b9DTJA0PMuC5Ii2RBywnfnpMf8WYYjzo3G7FQY1 4wEA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id d17-20020a170903231100b001c0c79b3869si3174846plh.578.2023.11.01.05.38.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Nov 2023 05:38:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id C0FCF80755D4; Wed, 1 Nov 2023 05:36:14 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235527AbjKAMgM (ORCPT + 99 others); Wed, 1 Nov 2023 08:36:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235188AbjKAMgL (ORCPT ); Wed, 1 Nov 2023 08:36:11 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0747D11B; Wed, 1 Nov 2023 05:36:06 -0700 (PDT) Received: from dggpemm500011.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4SL5y36YB1zrTPC; Wed, 1 Nov 2023 20:32:59 +0800 (CST) Received: from huawei.com (10.175.104.170) by dggpemm500011.china.huawei.com (7.185.36.110) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Wed, 1 Nov 2023 20:36:01 +0800 From: Ren Mingshuai To: CC: , , , , , , Subject: [PATCH] net: usbnet: Fix potential NULL pointer dereference Date: Wed, 1 Nov 2023 20:35:59 +0800 Message-ID: <20231101123559.210756-1-renmingshuai@huawei.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.104.170] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpemm500011.china.huawei.com (7.185.36.110) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 01 Nov 2023 05:36:14 -0700 (PDT) 23ba07991dad said SKB can be NULL without describing the triggering scenario. Always Check it before dereference to void potential NULL pointer dereference. Fix smatch warning: drivers/net/usb/usbnet.c:1380 usbnet_start_xmit() error: we previously assumed 'skb' could be null (see line 1359) Signed-off-by: Ren Mingshuai --- drivers/net/usb/usbnet.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c index 64a9a80b2309..386cb1a4ff03 100644 --- a/drivers/net/usb/usbnet.c +++ b/drivers/net/usb/usbnet.c @@ -1374,6 +1374,11 @@ netdev_tx_t usbnet_start_xmit (struct sk_buff *skb, } } + if (!skb) { + netif_dbg(dev, tx_err, dev->net, "tx skb is NULL\n"); + goto drop; + } + if (!(urb = usb_alloc_urb (0, GFP_ATOMIC))) { netif_dbg(dev, tx_err, dev->net, "no urb\n"); goto drop; -- 2.33.0