[PATCH 2/2] bus/vdev: fix a segfault when call callback
Min Hu (Connor)
humin29 at huawei.com
Sat May 21 09:05:23 CEST 2022
From: Huisong Li <lihuisong at huawei.com>
After the driver probe is executed, the callback in application will be
called. And this callback may call some APIs which access the driver in
struct rte_vdev_driver by the device::driver pointer to get some driver
information. If the rte_vdev_device::device::driver pointer isn't pointed
to the rte_vdev_driver::driver before executing driver probe, a segfault
will occur.
Fixes: e9d159c3d534 ("eal: allow probing a device again")
Cc: stable at dpdk.org
Signed-off-by: Huisong Li <lihuisong at huawei.com>
Signed-off-by: Min Hu (Connor) <humin29 at huawei.com>
---
drivers/bus/vdev/vdev.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/drivers/bus/vdev/vdev.c b/drivers/bus/vdev/vdev.c
index a8d8b2327e..dea3937607 100644
--- a/drivers/bus/vdev/vdev.c
+++ b/drivers/bus/vdev/vdev.c
@@ -209,9 +209,16 @@ vdev_probe_all_drivers(struct rte_vdev_device *dev)
return -1;
}
+ /*
+ * After the driver probe is executed, the callback in application will
+ * be called. The callback in application may call some APIs which use
+ * dev->device.driver to get some driver information. If the driver
+ * pointer isn't pointed to driver->driver here, a segfault will occur.
+ */
+ dev->device.driver = &driver->driver;
ret = driver->probe(dev);
- if (ret == 0)
- dev->device.driver = &driver->driver;
+ if (ret != 0)
+ dev->device.driver = NULL;
return ret;
}
--
2.33.0
More information about the stable
mailing list