Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp2685323pxy; Mon, 3 May 2021 05:56:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy+GRYQVc0ixAIi0EpkON0pNkHWp/EDrjCF9Eb92eUIdoNJHd0IpDtd+l/f9SPNw9bAKqIo X-Received: by 2002:a62:8f45:0:b029:28e:a5f2:2f2a with SMTP id n66-20020a628f450000b029028ea5f22f2amr3794740pfd.44.1620046603421; Mon, 03 May 2021 05:56:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620046603; cv=none; d=google.com; s=arc-20160816; b=yhLkFl8B+24+0YtRM/z3g3rAB+jeKtyWwiP4w+U8YB8+/2wWlCjb1J7GDlsNVlGzum baIVxG81hgBKLunKuyvAmsaanLXzlIVt7PtFBxakF2EQu0pFhZSQfGDFZsSks22I3U4y M+MbJ4hOiCgijEIHlVNym3U/VMHyyyer2xqk4Qb6rfqtINimZdBOGdpyancWB3yo4HUO JmUCZe5NzXQCNLHpBOQp8caj3IDQXWjffC8H3EyeNrlj+SrfNNR1g6YqZIylw1Ziyj/l JHyNKE8ej4CEASf2pAD54p7UmsqUF97aMiscHOmr+WtIA0cxU0KFxMzHmYHAhwHWRoLU W4NA== 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 :dkim-signature; bh=DjrqrNL/6DZOQMQzozY3R6cJ+7YpBS0O8INU4kc3Vn4=; b=smMwotHiJ+ad3qHiSukMgk2MpXlAQRhfFIYGip4EJHWMHWQiy4Lkbwt3Sa2gvNGXF+ DZfMZPZrWywFTzTm1vU/iVSf+/xSD06aRygBIBjyAjM8GSA57ScdVOay/95k1mLk+scW b7BaAPQxPPf6FuSx+Kr2ZRxtpW1MzSdjoT6T5y8eVJOXdNXKrBi1Kl+sNPjHR3Mee/UG b2CNFIFKifChoQeQZYfaj1Kb5IgnFkNktsh09SXH9dzL55jFm9Ax/X4j5b668X4F/grb t6pmG9rSbNHBNnvchdk6ipL0dHehW4tk5HQFIBoRexPpxFAykP288zoCXBD0Azqhtvta +hpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=YD0Rp3bh; 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 pf15si7815500pjb.68.2021.05.03.05.56.27; Mon, 03 May 2021 05:56: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=YD0Rp3bh; 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 S233654AbhECMAP (ORCPT + 99 others); Mon, 3 May 2021 08:00:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:34134 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233581AbhECMAI (ORCPT ); Mon, 3 May 2021 08:00:08 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 527E061249; Mon, 3 May 2021 11:59:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620043154; bh=PJFaOs6qCU5XbAWKeafMy7AGDXU8LXXpbcOyfgUx6RM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YD0Rp3bhcOCdPJ5li4O5nqRK00P/ll9YHzXMZsYiLi+Ul6kc04iDvMRz3BA3MAWkj avC37orhDlhcky7sTgFnPduwyGmXP5J1iO18FfqkhtxNU+dRbdrOFrbMumzInQCPW6 kTHyh+6t+tGIQQr+386W+toDDCGFu5wp5B2IgSwI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Du Cheng , "David S . Miller" , Greg Kroah-Hartman Subject: [PATCH 19/69] net: caif: remove BUG_ON(dev == NULL) in caif_xmit Date: Mon, 3 May 2021 13:56:46 +0200 Message-Id: <20210503115736.2104747-20-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210503115736.2104747-1-gregkh@linuxfoundation.org> References: <20210503115736.2104747-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Du Cheng 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 Signed-off-by: Greg Kroah-Hartman --- 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 a7f51eb58915..d17482395a4d 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.31.1