Skip to contentSkip to conversation

devargs: fix variadic parsing memory leak

PATCH Applied Gaetan Rivet 2 participants 2 messages Oct 17, 2018 – Oct 25, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 devargs: fix variadic parsing memory leak

rte_devargs_parsef will leak memory each time it is called. The device string must be freed.

Fixes a23bc2c4e01b ("devargs: add non-variadic parsing function")
---
 lib/librte_eal/common/eal_common_devargs.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
lib/librte_eal/common/eal_common_devargs.c +5 -1
index 69e9e32e9..c1b06095e 100644
@@ -237,6 +237,7 @@ rte_devargs_parsef(struct rte_devargs *da, const char *format, ...)
 	va_list ap;
 	size_t len;
 	char *dev;
+	int ret;
 
 	if (da == NULL)
 		return -EINVAL;
@@ -255,7 +256,10 @@ rte_devargs_parsef(struct rte_devargs *da, const char *format, ...)
 	vsnprintf(dev, len + 1, format, ap);
 	va_end(ap);
 
-	return rte_devargs_parse(da, dev);
+	ret = rte_devargs_parse(da, dev);
+
+	free(dev);
+	return ret;
 }
 
 int __rte_experimental
Signature · 1 line
2.19.0