[dpdk-dev] memzone: fix race condition on alloc failure

Message ID bd6904780d849ab2cebe2844d12f820903ae929e.1525337715.git.anatoly.burakov@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Anatoly Burakov May 3, 2018, 8:59 a.m. UTC
  Deallocation used the wrong function, which could have resulted in
race conditions because the function does not use locks internally.

Fixes: 1403f87d4fb8 ("malloc: enable memory hotplug support")
Cc: anatoly.burakov@intel.com

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 lib/librte_eal/common/eal_common_memzone.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Ananyev, Konstantin May 10, 2018, 2:30 p.m. UTC | #1
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Anatoly Burakov
> Sent: Thursday, May 3, 2018 9:59 AM
> To: dev@dpdk.org
> Cc: Burakov, Anatoly <anatoly.burakov@intel.com>
> Subject: [dpdk-dev] [PATCH] memzone: fix race condition on alloc failure
> 
> Deallocation used the wrong function, which could have resulted in
> race conditions because the function does not use locks internally.
> 
> Fixes: 1403f87d4fb8 ("malloc: enable memory hotplug support")
> Cc: anatoly.burakov@intel.com
> 
> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
> ---


Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
  
Thomas Monjalon May 13, 2018, 11:38 p.m. UTC | #2
> > Deallocation used the wrong function, which could have resulted in
> > race conditions because the function does not use locks internally.
> > 
> > Fixes: 1403f87d4fb8 ("malloc: enable memory hotplug support")
> > Cc: anatoly.burakov@intel.com
> > 
> > Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
> 
> Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>

Applied, thanks
  

Patch

diff --git a/lib/librte_eal/common/eal_common_memzone.c b/lib/librte_eal/common/eal_common_memzone.c
index bce3321..28f39e2 100644
--- a/lib/librte_eal/common/eal_common_memzone.c
+++ b/lib/librte_eal/common/eal_common_memzone.c
@@ -205,7 +205,7 @@  memzone_reserve_aligned_thread_unsafe(const char *name, size_t len,
 
 	if (mz == NULL) {
 		RTE_LOG(ERR, EAL, "%s(): Cannot find free memzone\n", __func__);
-		malloc_elem_free(elem);
+		malloc_heap_free(elem);
 		rte_errno = ENOSPC;
 		return NULL;
 	}