[dpdk-stable] patch 'service: fix possible mem leak on initialize' has been queued to LTS release 17.11.1

Yuanhan Liu yliu at fridaylinux.org
Thu Feb 1 10:47:16 CET 2018


Hi,

FYI, your patch has been queued to LTS release 17.11.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 02/03/18. So please
shout if anyone has objections.

Thanks.

	--yliu

---
>From 0fddb7867cd952540da7a56c23ea7df82dca158a Mon Sep 17 00:00:00 2001
From: Harry van Haaren <harry.van.haaren at intel.com>
Date: Wed, 24 Jan 2018 17:02:47 +0000
Subject: [PATCH] service: fix possible mem leak on initialize

[ upstream commit da9ac508c3b77c83c201dd01d7736ccf139d1767 ]

This commit ensures that if that if we run out of memory
during the initialization of the service library, that the
first allocated memory is correctly freed instead of leaked.

Fixes: 21698354c832 ("service: introduce service cores concept")

Reported-by: Vipin Varghese <vipin.varghese at intel.com>
Signed-off-by: Harry van Haaren <harry.van.haaren at intel.com>
---
 lib/librte_eal/common/rte_service.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/lib/librte_eal/common/rte_service.c b/lib/librte_eal/common/rte_service.c
index 9ff4136..1f92294 100644
--- a/lib/librte_eal/common/rte_service.c
+++ b/lib/librte_eal/common/rte_service.c
@@ -111,14 +111,14 @@ int32_t rte_service_init(void)
 			RTE_CACHE_LINE_SIZE);
 	if (!rte_services) {
 		printf("error allocating rte services array\n");
-		return -ENOMEM;
+		goto fail_mem;
 	}
 
 	lcore_states = rte_calloc("rte_service_core_states", RTE_MAX_LCORE,
 			sizeof(struct core_state), RTE_CACHE_LINE_SIZE);
 	if (!lcore_states) {
 		printf("error allocating core states array\n");
-		return -ENOMEM;
+		goto fail_mem;
 	}
 
 	int i;
@@ -135,6 +135,12 @@ int32_t rte_service_init(void)
 
 	rte_service_library_initialized = 1;
 	return 0;
+fail_mem:
+	if (rte_services)
+		rte_free(rte_services);
+	if (lcore_states)
+		rte_free(lcore_states);
+	return -ENOMEM;
 }
 
 /* returns 1 if service is registered and has not been unregistered
-- 
2.7.4



More information about the stable mailing list