From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gateway21.websitewelcome.com ([192.185.45.89]:34039 "EHLO gateway21.websitewelcome.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932665AbeGFNKr (ORCPT ); Fri, 6 Jul 2018 09:10:47 -0400 Received: from cm16.websitewelcome.com (cm16.websitewelcome.com [100.42.49.19]) by gateway21.websitewelcome.com (Postfix) with ESMTP id 67F94400C5F75 for ; Fri, 6 Jul 2018 08:10:46 -0500 (CDT) Date: Fri, 6 Jul 2018 08:10:44 -0500 From: "Gustavo A. R. Silva" To: Matthew Wilcox Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" Subject: [PATCH] xarray: Fix lock/unlock imbalance in xa_alloc Message-ID: <20180706131044.GA25469@embeddedor.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Sender: linux-fsdevel-owner@vger.kernel.org List-ID: Release *xa_lock* before return. Addresses-Coverity-ID: 1471631 ("Missing unlock") Fixes: 29a6bfc32eb2 ("xarray: Track free entries in an XArray") Signed-off-by: Gustavo A. R. Silva --- lib/xarray.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/xarray.c b/lib/xarray.c index be10039..a27fdb38 100644 --- a/lib/xarray.c +++ b/lib/xarray.c @@ -1474,8 +1474,10 @@ int xa_alloc(struct xarray *xa, u32 *id, void *entry, gfp_t gfp) xas.xa_index = 0; xas_lock(&xas); xas_find_tagged(&xas, UINT_MAX, XA_FREE_TAG); - if (xas.xa_node == XAS_BOUNDS && xas.xa_index == UINT_MAX + 1) + if (xas.xa_node == XAS_BOUNDS && xas.xa_index == UINT_MAX + 1) { + xas_unlock(&xas); return -ENOSPC; + } *id = xas.xa_index; xas_store(&xas, entry); xas_clear_tag(&xas, XA_FREE_TAG); -- 2.7.4