DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net/nbl: fix late device data check in configure callback
@ 2026-12-02 11:24 Oleg Kotkov
  2026-12-03 21:22 ` Stephen Hemminger
  0 siblings, 1 reply; 2+ messages in thread
From: Oleg Kotkov @ 2026-12-02 11:24 UTC (permalink / raw)
  To: dimon.zhao, leon.yu, sam.chen; +Cc: dev, Oleg Kotkov, stable

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>
---
When backporting to 25.11, also move the rx_mq_mode read below the
device data check.

 drivers/net/nbl/nbl_dev/nbl_dev.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/net/nbl/nbl_dev/nbl_dev.c b/drivers/net/nbl/nbl_dev/nbl_dev.c
index d28eea082f..1ab38efa81 100644
--- a/drivers/net/nbl/nbl_dev/nbl_dev.c
+++ b/drivers/net/nbl/nbl_dev/nbl_dev.c
@@ -13,11 +13,16 @@ static int nbl_dev_port_configure(struct nbl_adapter *adapter)
 
 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);
+	struct rte_eth_dev_data *dev_data;
+	struct nbl_adapter *adapter;
 	int ret;
 
-	if (dev_data == NULL || adapter == NULL)
+	dev_data = eth_dev->data;
+	if (dev_data == NULL)
+		return -EINVAL;
+
+	adapter = ETH_DEV_TO_NBL_DEV_PF_PRIV(eth_dev);
+	if (adapter == NULL)
 		return -EINVAL;
 
 	NBL_LOG(DEBUG, "Begin to configure the device, state: %d", adapter->state);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] net/nbl: fix late device data check in configure callback
  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
  0 siblings, 0 replies; 2+ messages in thread
From: Stephen Hemminger @ 2026-12-03 21:22 UTC (permalink / raw)
  To: Oleg Kotkov; +Cc: dimon.zhao, leon.yu, sam.chen, dev, stable

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.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-12-03 21:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox