[dpdk-stable] patch 'devargs: fix memory leak on parsing failure' has been queued to stable release 19.11.9

Christian Ehrhardt christian.ehrhardt at canonical.com
Mon May 17 18:08:52 CEST 2021


Hi,

FYI, your patch has been queued to stable release 19.11.9

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 05/19/21. So please
shout if anyone has objections.

Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.

Queued patches are on a temporary branch at:
https://github.com/cpaelzer/dpdk-stable-queue

This queued commit can be viewed at:
https://github.com/cpaelzer/dpdk-stable-queue/commit/4dc48d766c3ab8076786266d1bb6cfe1cd03d25c

Thanks.

Christian Ehrhardt <christian.ehrhardt at canonical.com>

---
>From 4dc48d766c3ab8076786266d1bb6cfe1cd03d25c Mon Sep 17 00:00:00 2001
From: Xueming Li <xuemingl at nvidia.com>
Date: Tue, 13 Apr 2021 03:14:09 +0000
Subject: [PATCH] devargs: fix memory leak on parsing failure

[ upstream commit e132ee8690474fa985e26f1d4db75823024748c8 ]

This patch fixes memory leak in parsing error handling.

Fixes: 338327d731e6 ("devargs: add function to parse device layers")

Signed-off-by: Xueming Li <xuemingl at nvidia.com>
Reviewed-by: Gaetan Rivet <grive at u256.net>
---
 lib/librte_eal/common/eal_common_devargs.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c
index 2123773ef8..0e350bc3ce 100644
--- a/lib/librte_eal/common/eal_common_devargs.c
+++ b/lib/librte_eal/common/eal_common_devargs.c
@@ -60,6 +60,7 @@ rte_devargs_layers_parse(struct rte_devargs *devargs,
 	size_t nblayer;
 	size_t i = 0;
 	int ret = 0;
+	bool allocated_data = false;
 
 	/* Split each sub-lists. */
 	nblayer = devargs_layer_count(devstr);
@@ -81,6 +82,7 @@ rte_devargs_layers_parse(struct rte_devargs *devargs,
 			ret = -ENOMEM;
 			goto get_out;
 		}
+		allocated_data = true;
 		s = devargs->data;
 	}
 
@@ -163,8 +165,14 @@ get_out:
 		if (layers[i].kvlist)
 			rte_kvargs_free(layers[i].kvlist);
 	}
-	if (ret != 0)
+	if (ret != 0) {
+		if (allocated_data) {
+			/* Free duplicated data. */
+			free(devargs->data);
+			devargs->data = NULL;
+		}
 		rte_errno = -ret;
+	}
 	return ret;
 }
 
-- 
2.31.1

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2021-05-17 17:40:33.492661267 +0200
+++ 0103-devargs-fix-memory-leak-on-parsing-failure.patch	2021-05-17 17:40:29.307810548 +0200
@@ -1 +1 @@
-From e132ee8690474fa985e26f1d4db75823024748c8 Mon Sep 17 00:00:00 2001
+From 4dc48d766c3ab8076786266d1bb6cfe1cd03d25c Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit e132ee8690474fa985e26f1d4db75823024748c8 ]
+
@@ -9 +10,0 @@
-Cc: stable at dpdk.org
@@ -18 +19 @@
-index 48f85ee9c0..e40b91ea66 100644
+index 2123773ef8..0e350bc3ce 100644


More information about the stable mailing list