diff mbox series

[RFC,2/9] devargs: fix memory leak on parsing error

Message ID 1608304614-13908-3-git-send-email-xuemingl@nvidia.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers show
Series support global syntax | expand

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Xueming(Steven) Li Dec. 18, 2020, 3:16 p.m. UTC
This patch fixes memory leak in parsing error handling.

Fixes: 338327d731e6 ("devargs: add function to parse device layers")
Cc: gaetan.rivet@6wind.com
Cc: stable@dpdk.org

Signed-off-by: Xueming Li <xuemingl@nvidia.com>
---
 lib/librte_eal/common/eal_common_devargs.c | 5 +++++
 1 file changed, 5 insertions(+)
diff mbox series

Patch

diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c
index fcf3d9a3cc..f36f71fbce 100644
--- a/lib/librte_eal/common/eal_common_devargs.c
+++ b/lib/librte_eal/common/eal_common_devargs.c
@@ -163,6 +163,11 @@  rte_devargs_layers_parse(struct rte_devargs *devargs,
 		if (layers[i].kvlist)
 			rte_kvargs_free(layers[i].kvlist);
 	}
+	if (ret && devargs->data && devargs->data != devstr) {
+		/* Free duplicated data. */
+		free(devargs->data);
+		devargs->data = NULL;
+	}
 	if (ret != 0)
 		rte_errno = -ret;
 	return ret;