From 7b681637d26eb91c1253c03e3d0268a7e3e29b66 Mon Sep 17 00:00:00 2001 From: Gaetan Rivet Date: Thu, 3 Aug 2017 14:34:31 +0200 Subject: [PATCH] eal: fix leak on hotplug parsing error If rte_eal_devargs_parse fails, the rte_devargs has not yet been inserted in the global list. When jumping to err_devarg, the removal fails and it is not properly freed. Free the allocated rte_devargs if its removal failed. Coverity issue: 158658 Fixes: 7e8b26650146 ("eal: fix hotplug add / remove") Signed-off-by: Gaetan Rivet --- lib/librte_eal/common/eal_common_dev.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/librte_eal/common/eal_common_dev.c b/lib/librte_eal/common/eal_common_dev.c index d19232d796..fc8a4d2278 100644 --- a/lib/librte_eal/common/eal_common_dev.c +++ b/lib/librte_eal/common/eal_common_dev.c @@ -204,7 +204,10 @@ int rte_eal_hotplug_add(const char *busname, const char *devname, return 0; err_devarg: - rte_eal_devargs_remove(busname, devname); + if (rte_eal_devargs_remove(busname, devname)) { + free(da->args); + free(da); + } err_name: free(name); return ret; -- 2.20.1