DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: Oleg Kotkov <Oleg.Kotkov@kaspersky.com>
Cc: <dimon.zhao@nebula-matrix.com>, <leon.yu@nebula-matrix.com>,
	<sam.chen@nebula-matrix.com>, <dev@dpdk.org>, <stable@dpdk.org>
Subject: Re: [PATCH] net/nbl: fix late device data check in configure callback
Date: Thu, 3 Dec 2026 13:22:46 -0800	[thread overview]
Message-ID: <20261203132246.5e2aa1aa@phoenix.local> (raw)
In-Reply-To: <20261202112444.2643835-1-Oleg.Kotkov@kaspersky.com>

On Wed, 2 Dec 2026 14:24:43 +0300
Oleg Kotkov <Oleg.Kotkov@kaspersky.com> wrote:

> nbl_dev_configure() reads eth_dev->data->dev_private before checking
> whether eth_dev->data is NULL. Move the adapter lookup after the check
> so the callback can return -EINVAL when device data is missing.
> 
> Fixes: 93b38df5a2ec ("net/nbl: support basic configuration")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Oleg Kotkov <Oleg.Kotkov@kaspersky.com>
> ---

Some AI review warnings:

Warning
-------

net/nbl: fix late device data check in configure callback

The reordered condition cannot occur, so the patch changes no
behaviour and only adds lines.

	dev_data = eth_dev->data;
	if (dev_data == NULL)
		return -EINVAL;

rte_eth_dev_configure() dereferences dev->data before it dispatches to
the PMD.  It reads dev->data->dev_started and then writes
dev->data->dev_configured = 0, both in rte_ethdev.c well ahead of the
dev_ops->dev_configure(dev) call at rte_ethdev.c:1672, which is the
only call site.  A NULL eth_dev->data would have crashed in ethdev and
never reached this callback.

The adapter check is unreachable for the same reason.
ETH_DEV_TO_NBL_DEV_PF_PRIV() returns eth_dev->data->dev_private, and
dev_private is allocated by rte_eth_dev_pci_allocate(), which calls
rte_eth_dev_release_port() and returns NULL if that allocation fails.
Probe then fails, so a port that reaches dev_configure always has a
non-NULL adapter.

Delete both checks instead of reordering them:

	int nbl_dev_configure(struct rte_eth_dev *eth_dev)
	{
		struct rte_eth_dev_data *dev_data = eth_dev->data;
		struct nbl_adapter *adapter =
			ETH_DEV_TO_NBL_DEV_PF_PRIV(eth_dev);
		int ret;

		NBL_LOG(DEBUG, "Begin to configure the device, state: %d",
			adapter->state);

With no reachable bug, drop the Fixes: tag and Cc: stable@dpdk.org as
well; there is nothing for the stable trees to pick up.


      reply	other threads:[~2026-12-03 21:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-02 11:24 [PATCH] net/nbl: fix late device data check in configure callback Oleg Kotkov
2026-12-03 21:22 ` Stephen Hemminger [this message]

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=20261203132246.5e2aa1aa@phoenix.local \
    --to=stephen@networkplumber.org \
    --cc=Oleg.Kotkov@kaspersky.com \
    --cc=dev@dpdk.org \
    --cc=dimon.zhao@nebula-matrix.com \
    --cc=leon.yu@nebula-matrix.com \
    --cc=sam.chen@nebula-matrix.com \
    --cc=stable@dpdk.org \
    /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