[PATCH v5 20/45] net/sxe2: fix null dereference in dev uninit
liujie5 at linkdatatechnology.com
liujie5 at linkdatatechnology.com
Fri Aug 28 05:25:04 CEST 2026
From: Jie Liu <liujie5 at linkdatatechnology.com>
sxe2_dev_uninit() calls rep_dev->dev_ops->dev_close() for each VF
representor without checking that dev_ops or dev_close is present,
which can crash when the representor device is not fully initialized.
Guard the call with NULL checks.
Fixes: 635084db5d57 ("net/sxe2: support VF representors")
Cc: stable at dpdk.org
Cc: stephen at networkplumber.org
Signed-off-by: Jie Liu <liujie5 at linkdatatechnology.com>
---
drivers/net/sxe2/sxe2_ethdev.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/net/sxe2/sxe2_ethdev.c b/drivers/net/sxe2/sxe2_ethdev.c
index fdff4ae10f..41ea67a607 100644
--- a/drivers/net/sxe2/sxe2_ethdev.c
+++ b/drivers/net/sxe2/sxe2_ethdev.c
@@ -2074,9 +2074,11 @@ static int32_t sxe2_dev_uninit(struct rte_eth_dev *dev)
for (i = 0; i < adapter->repr_ctxt.nb_repr_vf; i++) {
rep_dev = adapter->repr_ctxt.vf_rep_eth_dev[i];
if (rep_dev) {
- ret = rep_dev->dev_ops->dev_close(rep_dev);
- if (ret)
- goto l_end;
+ if (rep_dev->dev_ops && rep_dev->dev_ops->dev_close) {
+ ret = rep_dev->dev_ops->dev_close(rep_dev);
+ if (ret)
+ goto l_end;
+ }
if (rep_dev->intr_handle)
rte_intr_instance_free(rep_dev->intr_handle);
ret = rte_eth_dev_release_port(rep_dev);
--
2.52.0
More information about the dev
mailing list