Received: by 2002:a05:7412:f589:b0:e2:908c:2ebd with SMTP id eh9csp884581rdb; Wed, 1 Nov 2023 05:55:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEl34fgFPeBVl4xaIvwZBOU2jEC7kGrRh/T4T/R9beqAWZXjpdia+ntjzObomLM/3w2+Ttb X-Received: by 2002:a17:902:e544:b0:1cc:5c8f:4056 with SMTP id n4-20020a170902e54400b001cc5c8f4056mr7393764plf.42.1698843352238; Wed, 01 Nov 2023 05:55:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698843352; cv=none; d=google.com; s=arc-20160816; b=VQ6kinEAZ3F9XeczyW1z6jZkVkT1m3ZTlawFk7UBpnjo7wRwt7LkRKcrE/q3ovA4ek 7kEJMyF9QxbXl6g6MeVJx53ILF1hG4klpYNDeGZ35YeSQwBqVdjhEY851xMyPt9PNRL3 7ZrkuhssBIG4TvxtC5uuuvA9aSk3ErBVMjfX+4FpO9maeU0EgwlIGsqSkIihzlfBwrfG Y8naFGZQCoW7X1sqk5C6+Pdcz22VOGoP2pRHRT/1P5eMajYKfon4ZU8mWtO9DgwXrNJF uxbLFlucmuO5RERJIt6Ysfhm1Im5PB4+OMhN1hDJgH58nJztGlO8e1Z8XkHcGndkw5GU 3NoA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=CaoXbH9YqHeVqvU1KwdJ+MwsA335hnlri8az/sHPPWk=; fh=sj9Dbb5yw9ALDmGTBgByyBCESdQDymOFNNLaEHqbCKA=; b=pzgs4HKzOSyfvm/b9TGKuRut7l1ygRfEj65ALicqMCsLXmloxTrb4Q7ljbTU+6Klvj kg9q/mYb+Bwpqlv16919D6+vSZSmVPwM4nZ3i6vVwtnRB1/5rbNlDwyNEXEE4+OzLxHq D1BeqvMajZOUuMDIn7dkp8n/hIjadhLKl14EyD32WD1UlA1m1P3AQB65BvxgpfFhtbvx Y8xgXa8nd2p5Z3B3xwyUEnk93HD8tshxWj1HhqT3k/xOHf0elUJzg+34q5U4BFKq5Pbw nV9FBa+9sCZ+PdOjR4oKo16vNi2yJeJwQfYPzWteeOkGvcQTRJO+84xw3cI8nuJHzLej a60Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id o14-20020a170902d4ce00b001b80ecdcb88si3006838plg.473.2023.11.01.05.55.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Nov 2023 05:55:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (Postfix) with ESMTP id C57C880465F4; Wed, 1 Nov 2023 05:55:49 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343969AbjKAMzV (ORCPT + 99 others); Wed, 1 Nov 2023 08:55:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343924AbjKAMzT (ORCPT ); Wed, 1 Nov 2023 08:55:19 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2A15101; Wed, 1 Nov 2023 05:55:16 -0700 (PDT) Received: from dggpemm500011.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4SL6M03b1RzPnmN; Wed, 1 Nov 2023 20:51:08 +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:55:14 +0800 From: Ren Mingshuai To: CC: , , , , , , , Subject: Re: [PATCH] net: usbnet: Fix potential NULL pointer dereference Date: Wed, 1 Nov 2023 20:55:11 +0800 Message-ID: <20231101125511.222629-1-renmingshuai@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231101123559.210756-1-renmingshuai@huawei.com> References: <20231101123559.210756-1-renmingshuai@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.104.170] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm500011.china.huawei.com (7.185.36.110) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email 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 (lipwig.vger.email [0.0.0.0]); Wed, 01 Nov 2023 05:55:49 -0700 (PDT) >23ba07991dad said SKB can be NULL without describing the triggering >scenario. Always Check it before dereference to void potential NULL >pointer dereference. I've tried to find out the scenarios where SKB is NULL, but failed. It seems impossible for SKB to be NULL. If SKB can be NULL, please tell me the reason and I'd be very grateful. >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