From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from compass.polito.it (compass.polito.it [130.192.55.110]) by dpdk.org (Postfix) with ESMTP id 700B52C6C for ; Thu, 14 Apr 2016 15:48:52 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by compass.polito.it (Postfix) with ESMTP id 3BF81100379; Thu, 14 Apr 2016 15:48:52 +0200 (CEST) Authentication-Results: compass.polito.it (amavisd-new); dkim=pass (1024-bit key) reason="pass (just generated, assumed good)" header.d=studenti.polito.it DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= studenti.polito.it; h=x-mailer:message-id:date:date:subject :subject:cc:to:from:from:received:received; s=y2k10; t= 1460641731; bh=jhibcgEKWEfd9vIExt4iTaSP5RkEEB6mJixhgzQlKmg=; b=l hjvi4sFM3O2I9Nk6fP3xwiLdCFmcKCZSEilvHAGj0EjEWHLWvc9YCy2o0Z2JJGnP 3LVOigDXT0t9CWlj/2Y480eclGmpjrdmFZTNbzR6mm2zzQwtm6Hz2fSzUrQGuyxk Q1/f8tca27Onzg6ai4ZMiccYhYpeT+YqcXFnKVZ76M= X-Virus-Scanned: amavisd-new at studenti.polito.it X-Spam-Flag: NO X-Spam-Score: -5.784 X-Spam-Level: X-Spam-Status: No, score=-5.784 tagged_above=-100 required=3.5 tests=[ALL_TRUSTED=-5, AWL=0.716, BAYES_00=-1.5] autolearn=ham Received: from compass.polito.it ([127.0.0.1]) by localhost (compass.polito.it [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id wtSd-FcDq3YM; Thu, 14 Apr 2016 15:48:51 +0200 (CEST) Received: from localhost.localdomain (unknown [130.192.225.176]) (using TLSv1.2 with cipher AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: s203403@studenti.polito.it) by compass.polito.it (Postfix) with ESMTPSA id 64EC7100378; Thu, 14 Apr 2016 15:48:51 +0200 (CEST) From: Mauricio Vasquez B To: sergio.gonzalez.monroy@intel.com Cc: dev@dpdk.org Date: Thu, 14 Apr 2016 15:48:39 +0200 Message-Id: <1460641719-15231-1-git-send-email-mauricio.vasquezbernal@studenti.polito.it> X-Mailer: git-send-email 1.9.1 Subject: [dpdk-dev] [PATCH] mem: fix freeing of memzone used by ivshmem X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Apr 2016 13:48:52 -0000 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 --- lib/librte_eal/common/eal_common_memzone.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/librte_eal/common/eal_common_memzone.c b/lib/librte_eal/common/eal_common_memzone.c index 711c845..1fce906 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) + if (mcfg->memzone[idx].ioremap_addr != 0) { ret = -EINVAL; + goto error; + } #endif + + addr = mcfg->memzone[idx].addr; + if (addr == NULL) ret = -EINVAL; else if (mcfg->memzone_cnt == 0) { @@ -345,6 +349,10 @@ rte_memzone_free(const struct rte_memzone *mz) rte_free(addr); return ret; + +error: + rte_rwlock_write_unlock(&mcfg->mlock); + return ret; } /* -- 1.9.1