[dpdk-stable] patch 'mem: fix resource leak' has been queued to stable release 18.08.1

Kevin Traynor ktraynor at redhat.com
Thu Nov 22 17:49:11 CET 2018


Hi,

FYI, your patch has been queued to stable release 18.08.1

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 11/28/18. 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. If the code is different (ie: not only metadata diffs), due for example to
a change in context or macro names, please double check it.

Thanks.

Kevin Traynor

---
>From 1c80e6f838c2bdba592583259449b978c64ae778 Mon Sep 17 00:00:00 2001
From: Anatoly Burakov <anatoly.burakov at intel.com>
Date: Mon, 22 Oct 2018 13:57:03 +0100
Subject: [PATCH] mem: fix resource leak

[ upstream commit 198b66b9461c01558d4fb474d1485d1312bf2650 ]

Segment preallocation code allocates an array of structures on the
heap but does not free the memory afterwards. Fix it by freeing it
at the end of the function, and changing control flow to always go
through that code path.

Coverity issue: 323524
Fixes: 1dd342d0fdc4 ("mem: improve segment list preallocation")

Signed-off-by: Anatoly Burakov <anatoly.burakov at intel.com>
---
 lib/librte_eal/linuxapp/eal/eal_memory.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c b/lib/librte_eal/linuxapp/eal/eal_memory.c
index cc2d3fb69..f442dd5ec 100644
--- a/lib/librte_eal/linuxapp/eal/eal_memory.c
+++ b/lib/librte_eal/linuxapp/eal/eal_memory.c
@@ -2100,5 +2100,5 @@ memseg_primary_init(void)
 		int socket_id;
 	} *memtypes = NULL;
-	int i, hpi_idx, msl_idx;
+	int i, hpi_idx, msl_idx, ret = -1; /* fail unless told to succeed */
 	struct rte_memseg_list *msl;
 	uint64_t max_mem, max_mem_per_type;
@@ -2192,5 +2192,5 @@ memseg_primary_init(void)
 		RTE_LOG(ERR, EAL, "Cannot accommodate all memory types, please increase %s\n",
 			RTE_STR(CONFIG_RTE_MAX_MEMSEG_LISTS));
-		return -1;
+		goto out;
 	}
 
@@ -2252,5 +2252,5 @@ memseg_primary_init(void)
 					"No more space in memseg lists, please increase %s\n",
 					RTE_STR(CONFIG_RTE_MAX_MEMSEG_LISTS));
-				return -1;
+				goto out;
 			}
 			msl = &mcfg->memsegs[msl_idx++];
@@ -2258,13 +2258,17 @@ memseg_primary_init(void)
 			if (alloc_memseg_list(msl, pagesz, n_segs,
 					socket_id, cur_seglist))
-				return -1;
+				goto out;
 
 			if (alloc_va_space(msl)) {
 				RTE_LOG(ERR, EAL, "Cannot allocate VA space for memseg list\n");
-				return -1;
+				goto out;
 			}
 		}
 	}
-	return 0;
+	/* we're successful */
+	ret = 0;
+out:
+	free(memtypes);
+	return ret;
 }
 
-- 
2.19.0

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2018-11-22 16:47:32.765993431 +0000
+++ 0019-mem-fix-resource-leak.patch	2018-11-22 16:47:32.000000000 +0000
@@ -1,8 +1,10 @@
-From 198b66b9461c01558d4fb474d1485d1312bf2650 Mon Sep 17 00:00:00 2001
+From 1c80e6f838c2bdba592583259449b978c64ae778 Mon Sep 17 00:00:00 2001
 From: Anatoly Burakov <anatoly.burakov at intel.com>
 Date: Mon, 22 Oct 2018 13:57:03 +0100
 Subject: [PATCH] mem: fix resource leak
 
+[ upstream commit 198b66b9461c01558d4fb474d1485d1312bf2650 ]
+
 Segment preallocation code allocates an array of structures on the
 heap but does not free the memory afterwards. Fix it by freeing it
 at the end of the function, and changing control flow to always go
@@ -10,7 +12,6 @@
 
 Coverity issue: 323524
 Fixes: 1dd342d0fdc4 ("mem: improve segment list preallocation")
-Cc: stable at dpdk.org
 
 Signed-off-by: Anatoly Burakov <anatoly.burakov at intel.com>
 ---
@@ -18,31 +19,31 @@
  1 file changed, 10 insertions(+), 6 deletions(-)
 
 diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c b/lib/librte_eal/linuxapp/eal/eal_memory.c
-index 19e686eb6..fce86fda6 100644
+index cc2d3fb69..f442dd5ec 100644
 --- a/lib/librte_eal/linuxapp/eal/eal_memory.c
 +++ b/lib/librte_eal/linuxapp/eal/eal_memory.c
-@@ -2136,5 +2136,5 @@ memseg_primary_init(void)
+@@ -2100,5 +2100,5 @@ memseg_primary_init(void)
  		int socket_id;
  	} *memtypes = NULL;
 -	int i, hpi_idx, msl_idx;
 +	int i, hpi_idx, msl_idx, ret = -1; /* fail unless told to succeed */
  	struct rte_memseg_list *msl;
  	uint64_t max_mem, max_mem_per_type;
-@@ -2228,5 +2228,5 @@ memseg_primary_init(void)
+@@ -2192,5 +2192,5 @@ memseg_primary_init(void)
  		RTE_LOG(ERR, EAL, "Cannot accommodate all memory types, please increase %s\n",
  			RTE_STR(CONFIG_RTE_MAX_MEMSEG_LISTS));
 -		return -1;
 +		goto out;
  	}
  
-@@ -2288,5 +2288,5 @@ memseg_primary_init(void)
+@@ -2252,5 +2252,5 @@ memseg_primary_init(void)
  					"No more space in memseg lists, please increase %s\n",
  					RTE_STR(CONFIG_RTE_MAX_MEMSEG_LISTS));
 -				return -1;
 +				goto out;
  			}
  			msl = &mcfg->memsegs[msl_idx++];
-@@ -2294,13 +2294,17 @@ memseg_primary_init(void)
+@@ -2258,13 +2258,17 @@ memseg_primary_init(void)
  			if (alloc_memseg_list(msl, pagesz, n_segs,
  					socket_id, cur_seglist))
 -				return -1;


More information about the stable mailing list