The vdev_probe calls driver->probe, which may fail
and dev->device.driver will still be NULL.

In vdev_cleanup, drv = container_of(dev->device.driver) returns !NULL,
then drv->remove will trigger Segmentation fault.
Fix it by checking dev->device.driver first.

Log:
Thread 1 "dpdk-test" received signal SIGSEGV, Segmentation fault.
0x00000000012c484d in vdev_cleanup ()

Signed-off-by: Zhangfei Gao <zhangfei....@linaro.org>
---
 drivers/bus/vdev/vdev.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/bus/vdev/vdev.c b/drivers/bus/vdev/vdev.c
index f5b43f1930..fbdaf68380 100644
--- a/drivers/bus/vdev/vdev.c
+++ b/drivers/bus/vdev/vdev.c
@@ -577,6 +577,9 @@ vdev_cleanup(void)
                const struct rte_vdev_driver *drv;
                int ret = 0;
 
+               if (dev->device.driver == NULL)
+                       continue;
+
                drv = container_of(dev->device.driver, const struct 
rte_vdev_driver, driver);
 
                if (drv == NULL || drv->remove == NULL)
-- 
2.36.1

Reply via email to