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: [email protected]

Signed-off-by: Oleg Kotkov <[email protected]>
---
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

Reply via email to