From: Mauricio Vasquez B Date: Fri, 15 Apr 2016 08:29:49 +0000 (+0200) Subject: mem: fix freeing of memzone used by ivshmem X-Git-Tag: spdx-start~6984 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=31ca33ff9311a6e377fdad028e41b9d11a0c35e2;p=dpdk.git mem: fix freeing of memzone used by ivshmem Although previous implementation returned an error when trying to release a memzone assigned to an ivshmem device, it stills freed it. Fixes: cd10c42eb5bc ("mem: fix ivshmem freeing") Signed-off-by: Mauricio Vasquez B Acked-by: Sergio Gonzalez Monroy --- diff --git a/lib/librte_eal/common/eal_common_memzone.c b/lib/librte_eal/common/eal_common_memzone.c index 711c8457f4..a8f804c14d 100644 --- a/lib/librte_eal/common/eal_common_memzone.c +++ b/lib/librte_eal/common/eal_common_memzone.c @@ -321,15 +321,19 @@ rte_memzone_free(const struct rte_memzone *mz) idx = ((uintptr_t)mz - (uintptr_t)mcfg->memzone); idx = idx / sizeof(struct rte_memzone); - addr = mcfg->memzone[idx].addr; #ifdef RTE_LIBRTE_IVSHMEM /* * If ioremap_addr is set, it's an IVSHMEM memzone and we cannot * free it. */ - if (mcfg->memzone[idx].ioremap_addr != 0) - ret = -EINVAL; + if (mcfg->memzone[idx].ioremap_addr != 0) { + rte_rwlock_write_unlock(&mcfg->mlock); + return -EINVAL; + } #endif + + addr = mcfg->memzone[idx].addr; + if (addr == NULL) ret = -EINVAL; else if (mcfg->memzone_cnt == 0) {