From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 330D5A05D3 for ; Fri, 29 Mar 2019 11:57:25 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1C9AB3977; Fri, 29 Mar 2019 11:57:13 +0100 (CET) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id 558264C9F for ; Fri, 29 Mar 2019 11:57:11 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Mar 2019 03:57:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,284,1549958400"; d="scan'208";a="146312056" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga002.jf.intel.com with ESMTP; 29 Mar 2019 03:57:09 -0700 Received: from sivswdev05.ir.intel.com (sivswdev05.ir.intel.com [10.243.17.64]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id x2TAv8CB017545; Fri, 29 Mar 2019 10:57:08 GMT Received: from sivswdev05.ir.intel.com (localhost [127.0.0.1]) by sivswdev05.ir.intel.com with ESMTP id x2TAv8BX001511; Fri, 29 Mar 2019 10:57:08 GMT Received: (from aburakov@localhost) by sivswdev05.ir.intel.com with LOCAL id x2TAv8pD001506; Fri, 29 Mar 2019 10:57:08 GMT From: Anatoly Burakov To: dev@dpdk.org Cc: dariusz.stojaczyk@intel.com, gavin.hu@arm.com Date: Fri, 29 Mar 2019 10:57:08 +0000 Message-Id: <35fe9a105fbf7868fc34cef330745b33acd0527c.1553856703.git.anatoly.burakov@intel.com> X-Mailer: git-send-email 1.7.0.7 Subject: [dpdk-dev] [PATCH] fbarray: fix init unlock without lock X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Content-Type: text/plain; charset="UTF-8" Message-ID: <20190329105708.Ngn0MSi63XLtyoHUjCDfwncCvqleGFV-YBHlWnzOS2Q@z> Certain failure paths of rte_fbarray_init() will unlock the mem area lock without locking it first. Fix this by properly handling the failures. Fixes: 5b61c62cfd76 ("fbarray: add internal tailq for mapped areas") Signed-off-by: Anatoly Burakov --- lib/librte_eal/common/eal_common_fbarray.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/librte_eal/common/eal_common_fbarray.c b/lib/librte_eal/common/eal_common_fbarray.c index 0e7366e5e..f852c7f50 100644 --- a/lib/librte_eal/common/eal_common_fbarray.c +++ b/lib/librte_eal/common/eal_common_fbarray.c @@ -736,15 +736,19 @@ rte_fbarray_init(struct rte_fbarray *arr, const char *name, unsigned int len, } page_sz = sysconf(_SC_PAGESIZE); - if (page_sz == (size_t)-1) - goto fail; + if (page_sz == (size_t)-1) { + free(ma); + return -1; + } /* calculate our memory limits */ mmap_len = calc_data_size(page_sz, elt_sz, len); data = eal_get_virtual_area(NULL, &mmap_len, page_sz, 0, 0); - if (data == NULL) - goto fail; + if (data == NULL) { + free(ma); + return -1; + } rte_spinlock_lock(&mem_area_lock); -- 2.17.1