public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Dave Jiang <dave.jiang@intel.com>
To: Alok Tiwari <alok.a.tiwari@oracle.com>,
	pabeni@redhat.com, kuba@kernel.org, edumazet@google.com,
	davem@davemloft.net, andrew+netdev@lunn.ch, jdmason@kudzu.us,
	allenbh@gmail.com, ntb@lists.linux.dev, netdev@vger.kernel.org
Cc: alok.a.tiwarilinux@gmail.com
Subject: Re: [PATCH net-next] net: ntb_netdev: Fix NULL check ordering in TX handler
Date: Tue, 24 Feb 2026 07:42:18 -0700	[thread overview]
Message-ID: <07904415-19a8-4381-9292-2f0625fd69ca@intel.com> (raw)
In-Reply-To: <20260224130458.1355686-1-alok.a.tiwari@oracle.com>



On 2/24/26 6:04 AM, Alok Tiwari wrote:
> ntb_netdev_tx_handler() calls netdev_priv(ndev) before checking
> whether ndev is NULL. Although qp_data is expected to always be
> valid in normal operation, dereferencing the pointer before the
> NULL check is logically incorrect.
> 
> Move netdev_priv() after validating ndev.
> 
> No functional change intended.
> 
> Signed-off-by: Alok Tiwari <alok.a.tiwari@oracle.com>

Acked-by: Dave Jiang <dave.jiang@intel.com>

> ---
>  drivers/net/ntb_netdev.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ntb_netdev.c b/drivers/net/ntb_netdev.c
> index fbeae05817e9..6792b3b1f253 100644
> --- a/drivers/net/ntb_netdev.c
> +++ b/drivers/net/ntb_netdev.c
> @@ -177,13 +177,15 @@ static void ntb_netdev_tx_handler(struct ntb_transport_qp *qp, void *qp_data,
>  				  void *data, int len)
>  {
>  	struct net_device *ndev = qp_data;
> +	struct ntb_netdev *dev;
>  	struct sk_buff *skb;
> -	struct ntb_netdev *dev = netdev_priv(ndev);
>  
>  	skb = data;
>  	if (!skb || !ndev)
>  		return;
>  
> +	dev = netdev_priv(ndev);
> +
>  	if (len > 0) {
>  		ndev->stats.tx_packets++;
>  		ndev->stats.tx_bytes += skb->len;


  reply	other threads:[~2026-02-24 14:42 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-24 13:04 [PATCH net-next] net: ntb_netdev: Fix NULL check ordering in TX handler Alok Tiwari
2026-02-24 14:42 ` Dave Jiang [this message]
2026-02-26  3:22 ` Jakub Kicinski
2026-02-26 14:14   ` ALOK TIWARI

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=07904415-19a8-4381-9292-2f0625fd69ca@intel.com \
    --to=dave.jiang@intel.com \
    --cc=allenbh@gmail.com \
    --cc=alok.a.tiwari@oracle.com \
    --cc=alok.a.tiwarilinux@gmail.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=jdmason@kudzu.us \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=ntb@lists.linux.dev \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox