Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2744470pxj; Mon, 31 May 2021 09:38:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwKBpWH8V2d8zOry7WTYxbFEpp6JuN5b6Zt449LeEMpyW+MEmFCTX05lFRvteii1y7foiQd X-Received: by 2002:aa7:c7c7:: with SMTP id o7mr23715027eds.231.1622479123205; Mon, 31 May 2021 09:38:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622479123; cv=none; d=google.com; s=arc-20160816; b=txnHrl7zcbInEuMF96Ndf0rNALx5s8Q1wLwTHaQcVoWQ2yDcDJDJ9WM1XtQFHRlD8x ETqpsCfQ33jmA8j6p1oAckfMYFNLGudRdfytMLqkNWVJmYmW0HIGsQ/SAysHuv5dcYno aup4YqCjMIlLwo69C1QWIIhO5EGxqZIxfqDXh7fHKHfJZzTV9pbaxU9ZYG5bfjQXuH08 cv8oxOwsG9QAnibAL6+L2nT0h0hkJNL0i21FRmsWaCkpzYq7icpxf9Phvp+uw3Z0SfUe 3rjxEB5UcNtexB92L00a2TyyMnuVWRHezkLeXcYXWRsjuA5vOAC/cvmkvCBNmU150OgV a4EQ== 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=/sF4zCK35YZhPJ3qCUalgQkv4G+L0FuonLxc6WdZSfk=; b=qmmqGzqc+Z3NrMu5mx4C83X06SkLohSl7TB0SAHcJs1h/f5K/eEGHiRKHgCftZk8MM c61jzK8iGzy5yf2utVVhA7dE7c7wwjGm59QXEwy3ZnTZHRhgx7QfBR0mM7vSkYB7+Ryb GwlxhpauvJVbiZ8eGS9A232VDuuCaBqAwHWoYIq0mHLDqn4zRDCYNquRyyLKGPRxehuK OHe/JYcl1Z/xMiUyZfQD2vReZiC7jPuGmGEfcQ0smxy6/frBQ63dRHYh3oeItisl9W4t ra0k2nVAF4WcAAFaNllDcUBhY9HSL1hz0AqTKhjDXBt0JXg3TsTpfB4P+XHkUEK9z6w1 i2bA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zm1mYVmq; 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 a92si9179457edf.232.2021.05.31.09.37.59; Mon, 31 May 2021 09:38:43 -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=zm1mYVmq; 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 S233478AbhEaQin (ORCPT + 99 others); Mon, 31 May 2021 12:38:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:40788 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232230AbhEaOto (ORCPT ); Mon, 31 May 2021 10:49:44 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E376C61C98; Mon, 31 May 2021 13:57:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622469442; bh=28GVIGDUXWSAXBjqsCOkpGQInfaziB5sPJg0exSEj/c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zm1mYVmqVtYz/iRqVfkV48jmdz7KnfKIaZex+zf2jc5zRbbus0j28iZbRKInkIzxt 3cpRfnbtmU2aIfY2XID8EDPj3vtY1m3sUQuJ8BkUt+Df2cDFqy7KuPR9vIR4I6a69l Y3JFaDcFA3e4T+6n95R+KCI8Hi0dq6g0t+Eh52l4= 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.12 172/296] net: caif: remove BUG_ON(dev == NULL) in caif_xmit Date: Mon, 31 May 2021 15:13:47 +0200 Message-Id: <20210531130709.657986435@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130703.762129381@linuxfoundation.org> References: <20210531130703.762129381@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 4720a7bac4fb..9f30748da4ab 100644 --- a/drivers/net/caif/caif_serial.c +++ b/drivers/net/caif/caif_serial.c @@ -269,7 +269,6 @@ static netdev_tx_t 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