From: Jie Liu <[email protected]>
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: 635084db5d ("net/sxe2: support VF representors")
Cc: [email protected]
Cc: [email protected]
Signed-off-by: Jie Liu <[email protected]>
---
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 7e3eb6432c..575ad299f1 100644
--- a/drivers/net/sxe2/sxe2_ethdev.c
+++ b/drivers/net/sxe2/sxe2_ethdev.c
@@ -2078,9 +2078,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