Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2623846pxj; Mon, 31 May 2021 06:49:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyPxojLtYpLtlYt9eGn1leyAz7j0ZvVtvTrX6PNjAR8xZooegtvpQOxUtxjFi/wi1dD20VP X-Received: by 2002:a92:7f07:: with SMTP id a7mr16873203ild.202.1622468973932; Mon, 31 May 2021 06:49:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622468973; cv=none; d=google.com; s=arc-20160816; b=utPcZjb4UZENXsBX2RAL6QiwHvZ+oqzuk6vSJuuUuj+rjlu0eTA0r7nIXopgJDWd7M eW4YfYaYs/lo0DnNTMY1HheQtXVaaRexe4SpGvXz8S43Kxv0YJi3yMlaYR0Pqr/ktFC7 +WykwFbkx0Nx4kI5WQM8Oelrm0opt+eRXtiKA3YtWJJClBLZ5ixtD7Q6Y9lPg0B6BVam VHxfGyBzYeT60/AOJkB8JCwKzmv/rFd1eb3pe2l8ogVFkvHB072Ha6Glsuj75DSlgsdL vXcWryqjDiJiplJb0FcMHP14e1SrWPhwts9PxG0OqL+eeflPsBeAhNOATLNUoBcjwZIE TT8Q== 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=WBzXebFBtbzh6Mr43GMj9oDc3h04WF4eH97k4hD453o=; b=F9hXkuA8Y7RFfMiX3kqAh6ouXyhw7adtKhybFMYqMAwJThGxmqfzQmnGPCNPGdVztz 8S2R7KgWk4Jxl9lSoZd5wqX7r5FK552aaRpTmNqiGtvJXkTou0wtk7rdpM5QJczWa0dA g7zj9HOu+5ghqiUVadb3R7RRfMBSShVzGfOpbPTwEBsxjBjqj/jXnQxTN1jUgJXSZxV0 6AKRmiE+nihHW7gPSJaIe5AO6kHJSNyJRXE4WXqTfRYWRsNl46F0FbRVq7uLsCGw34j1 dgEDiOhiWqEtRP/WJhlQ+iY9O1KZqVVORbHTVK0eVVXlbtEDVY9nHAKqMnBK3Af5MqUr lkTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=PcanPdL+; 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 k64si13774236iof.43.2021.05.31.06.49.18; Mon, 31 May 2021 06:49:33 -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=PcanPdL+; 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 S233149AbhEaNuB (ORCPT + 99 others); Mon, 31 May 2021 09:50:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:39134 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231629AbhEaNdY (ORCPT ); Mon, 31 May 2021 09:33:24 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 779266143B; Mon, 31 May 2021 13:24:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622467470; bh=tQZdtYbWLdg5SswCUN0BLKrwEcQO7/7BTQOA25kVGX4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PcanPdL+ghM51iPoNiBY+Nng/venKJ/aIzy/vd/ZNrs0ry+lK4XhTya+AciNALLPE +wQ/PBAJOaGP6wdB88eH1n8TeeVnN6c/M4fDXSGaDZzuP6m9N+WfEeRfSUUPM6Pi74 z7bB2QNjbhcPJZSHiW10cNZ+PGnkCcL3nGEbrnjs= 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 4.19 078/116] net: caif: remove BUG_ON(dev == NULL) in caif_xmit Date: Mon, 31 May 2021 15:14:14 +0200 Message-Id: <20210531130642.799243355@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130640.131924542@linuxfoundation.org> References: <20210531130640.131924542@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 a0f954f36c09..94d5ce9419ca 100644 --- a/drivers/net/caif/caif_serial.c +++ b/drivers/net/caif/caif_serial.c @@ -279,7 +279,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