Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2664817pxj; Mon, 31 May 2021 07:45:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxUTVxu9fRwnGMvitA9UjbZpOa4QSyTIjttoJw7lGmuTb48vSIq+i+e+AQFPZksiGTgoepa X-Received: by 2002:a17:906:5d14:: with SMTP id g20mr1519968ejt.243.1622472333984; Mon, 31 May 2021 07:45:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622472333; cv=none; d=google.com; s=arc-20160816; b=DqDp5n7bgMyp9eI4rioXEBnQwS7g7YXpApGIhJrSEeKyku5z2MFgPRAoRhNjtXnW2K 7tMvPaV+e4JyMqjUm86vldpeCF9iQmBp9bFUIsvIUuRsrPWE+kazMQN/TUP55BM0rtKR 1bY8RLw28QDttE3An5NR8hdsy8bG9H+uuvL1PotutdYL7uQF1KYCFCN5DAdPkR+bnKak 546o14sCXuo3g+Xjc+GcPOfcon6KCpvb3JIcTQBUuzMWJ5c9H+Ta77nGpxzNorHH5ILp 9ZF8Bt2k4+/o+H9Km5/AymxjUrhaqiCt8q8LUl5krdZ5mE8oc8/ab63tFGh70mXr32uL WuFA== 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=KzADVTm0M3tmYFpdmPqwQU1D3/nWJYcvHGH6T345F8Y=; b=iopYAqxgg7HOu5GWQRfWsNdrgUHsA3mmQpX6MZss/euJulXGPFnBvArxxhknDQf/rJ VT4iEPsylquYIvZ0Ld/9UbREpvJO0wvUbotl69LmtpDJjwH3EIvT8I/qH+9vfMLQ/s+S S3rBx5lloR/Z5Fw+8Ybsuwibo7l2bnmfh50p5SkNbvRIiYq+LtY/f1Q/NkvaSgTcPH2D D1yChE3dO0um0wuQp6Zq/2y2JsWhscDi4TEplns4NcmMCuy66epXVTUPhu0gSrIuTc8W 6EDpugmTFL+HusxIbzbmXrG8Chkmc0AY1XOE9uff1htDT3Xvt5P/UXaXQdtgszXgmGf9 k9Kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BYUbC2mI; 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 d26si14486788edr.567.2021.05.31.07.45.11; Mon, 31 May 2021 07:45: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=BYUbC2mI; 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 S233231AbhEaOpj (ORCPT + 99 others); Mon, 31 May 2021 10:45:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:60394 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232370AbhEaN7y (ORCPT ); Mon, 31 May 2021 09:59:54 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9922361939; Mon, 31 May 2021 13:36:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622468171; bh=jYqDL+I9kZOneNYVRANxYd++P+JHUVeq3BCBsUnBv8I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BYUbC2mI8HVCJDPVWHxkziN+fVA4z2QrPn7x5furqgLRUWCB3WhFU35giUR+oyXBB hSZlDow3QeygfekLwjcziDlYEzqLs431PJKRIrqjS5TmdOY1gAu8vF2w+cdh+i2rtg H/C9Ax3cQOxORCmGtMHFTA+uYY/Cu7gAoMvVKcL8= 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.10 142/252] net: caif: remove BUG_ON(dev == NULL) in caif_xmit Date: Mon, 31 May 2021 15:13:27 +0200 Message-Id: <20210531130702.835007478@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130657.971257589@linuxfoundation.org> References: <20210531130657.971257589@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 4cc0d91d9c87..d025ea434933 100644 --- a/drivers/net/caif/caif_serial.c +++ b/drivers/net/caif/caif_serial.c @@ -270,7 +270,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