Use the new rte_eal_devargs_rmv() API to free allocated resources during device removal or when encountering errors when adding devices.
Signed-off-by: Gaetan Rivet <gaetan.ri...@6wind.com> --- lib/librte_eal/common/eal_common_dev.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/librte_eal/common/eal_common_dev.c b/lib/librte_eal/common/eal_common_dev.c index 708c8e9..143c231 100644 --- a/lib/librte_eal/common/eal_common_dev.c +++ b/lib/librte_eal/common/eal_common_dev.c @@ -177,7 +177,7 @@ rte_eal_hotplug_add(const char *busname, const char *devname, ret = bus->scan(); if (ret) { rte_errno = -ret; - goto err_name; + goto err_devarg; } dev = bus->find_device(NULL, cmp_detached_dev_name, devname); @@ -185,7 +185,7 @@ rte_eal_hotplug_add(const char *busname, const char *devname, RTE_LOG(ERR, EAL, "Cannot find unplugged device (%s)\n", devname); rte_errno = EINVAL; - goto err_name; + goto err_devarg; } ret = bus->plug(dev, devargs); @@ -193,11 +193,13 @@ rte_eal_hotplug_add(const char *busname, const char *devname, RTE_LOG(ERR, EAL, "Driver cannot attach the device (%s)\n", dev->name); rte_errno = -ret; - goto err_name; + goto err_devarg; } free(name); return dev; +err_devarg: + rte_eal_devargs_rmv(busname, devname); err_name: free(name); return NULL; @@ -230,6 +232,8 @@ int rte_eal_hotplug_remove(const char *busname, const char *devname) return -EINVAL; } + rte_eal_devargs_rmv(busname, devname); + dev->devargs = NULL; ret = bus->unplug(dev); if (ret) { RTE_LOG(ERR, EAL, "Driver cannot detach the device (%s)\n", -- 2.1.4