Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2794891pxj; Mon, 31 May 2021 10:58:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwio55sU4AUGR7FhRyq6xzB7RNHyj+RIR+VAuj2hYFWr1LgGxDbsErHRK+25U/gbiWUgJkE X-Received: by 2002:a17:906:cd27:: with SMTP id oz39mr778377ejb.429.1622483884333; Mon, 31 May 2021 10:58:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622483884; cv=none; d=google.com; s=arc-20160816; b=kEMuowkWJKU6STyWv99+I+Z92CkH1WzzBnxwRQIhWNbbjXDlQp7a8raqFcKaVK+UVq 77k0TtjkRRqUbqxcPCm4YVCQVVYQmKTAYYO8HyZBjzGlmL+EdZIko5N4cjfL7yWJ/FhS HVgoMfhYssMnyr898PlPor4ktTFijrLvAWFv9m7QvXtpCpYA+QQ2scefe1FQWZEnkfhn U9lQ7TBAgs2p5olXPg96FbRrn+QhmYyvVcgCw0W/wabJa0mNuVopV/wUu/tyVWGEjoYR iOfxoPsJSMyEBb65DKC6E6G7XJwH7QyTNDy5h92YZKdVmOdxeNMA60M+Fc/3VquyKuwD iXww== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=y5ebK010PkVy2oz6GxPtCH4sy2rlYBbO/PHUAVE8Wm4=; b=wrYVlBF44P8/2hKwBbBIqrY5j05zzCOhQltyNst/e+UDMULxyoMZk5y0niHzUqA6Iz o2ArddMPrpkeHNesWB5ypMD9G0JWC4DIUcDyyYjK+BAauLVDhf047ATxsqqIjYrcT90o /JCjk24Ij0MlC70x5g2PNhRW0jwv49d7LOuyCDlOc4z1WeIJe8isoj66RLMvFJmDXrYg WFdtG/swlcMAZ6b4XrqhluJLoTRpt8+ecO2IdOwO0uyf7r9XVyUYDdtQMu6kIhiye6r3 KiETl0M7CtakNM1n2mrxdoD3QbhoKoC5s/gGUNR3E6QTGLehXsaliOGNG39RdkLmk1Ci RHKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lbS6uvAD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i19si13305555edc.501.2021.05.31.10.57.41; Mon, 31 May 2021 10:58:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lbS6uvAD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234742AbhEaPgK (ORCPT + 99 others); Mon, 31 May 2021 11:36:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:48836 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233862AbhEaOVb (ORCPT ); Mon, 31 May 2021 10:21:31 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1A212619C6; Mon, 31 May 2021 13:45:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622468703; bh=xT4oh+Kl9yrAfIuii1ZRMFpk90BZcWnx60uANb60MVg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lbS6uvADc9P7IfGO6+1NyvExTicnPDC1AA7hM52HZzheqPYEvM5Vv1pxstdHXGdD9 bsmGZLtAv7klsUWvgDXDAzn1W02fR4JRCfA4fGmzZFa2kSr4N6Z05TzWXCmBnZC6Sg aPaI154qyNNKuuhbC+U7y15Ja0AoekWR5Zw/RX1w= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "David S. Miller" , Du Cheng , Sasha Levin Subject: [PATCH 5.4 095/177] net: caif: remove BUG_ON(dev == NULL) in caif_xmit Date: Mon, 31 May 2021 15:14:12 +0200 Message-Id: <20210531130651.173995740@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130647.887605866@linuxfoundation.org> References: <20210531130647.887605866@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Du Cheng [ Upstream commit 65a67792e3416f7c5d7daa47d99334cbb19a7449 ] The condition of dev == NULL is impossible in caif_xmit(), hence it is for the removal. Explanation: The static caif_xmit() is only called upon via a function pointer `ndo_start_xmit` defined in include/linux/netdevice.h: ``` struct net_device_ops { ... netdev_tx_t (*ndo_start_xmit)(struct sk_buff *skb, struct net_device *dev); ... } ``` The exhausive list of call points are: ``` drivers/net/ethernet/qualcomm/rmnet/rmnet_map_command.c dev->netdev_ops->ndo_start_xmit(skb, dev); ^ ^ drivers/infiniband/ulp/opa_vnic/opa_vnic_netdev.c struct opa_vnic_adapter *adapter = opa_vnic_priv(netdev); ^ ^ return adapter->rn_ops->ndo_start_xmit(skb, netdev); // adapter would crash first ^ ^ drivers/usb/gadget/function/f_ncm.c ncm->netdev->netdev_ops->ndo_start_xmit(NULL, ncm->netdev); ^ ^ include/linux/netdevice.h static inline netdev_tx_t __netdev_start_xmit(... { return ops->ndo_start_xmit(skb, dev); ^ } const struct net_device_ops *ops = dev->netdev_ops; ^ rc = __netdev_start_xmit(ops, skb, dev, more); ^ ``` In each of the enumerated scenarios, it is impossible for the NULL-valued dev to reach the caif_xmit() without crashing the kernel earlier, therefore `BUG_ON(dev == NULL)` is rather useless, hence the removal. Cc: David S. Miller Signed-off-by: Du Cheng Link: https://lore.kernel.org/r/20210503115736.2104747-20-gregkh@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/net/caif/caif_serial.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/net/caif/caif_serial.c b/drivers/net/caif/caif_serial.c index 40b079162804..0f2bee59a82b 100644 --- a/drivers/net/caif/caif_serial.c +++ b/drivers/net/caif/caif_serial.c @@ -270,7 +270,6 @@ static int caif_xmit(struct sk_buff *skb, struct net_device *dev) { struct ser_device *ser; - BUG_ON(dev == NULL); ser = netdev_priv(dev); /* Send flow off once, on high water mark */ -- 2.30.2