From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
To: Matthew Wilcox <willy@infradead.org>
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
"Gustavo A. R. Silva" <gustavo@embeddedor.com>
Subject: [PATCH] xarray: Fix lock/unlock imbalance in xa_alloc
Date: Fri, 6 Jul 2018 08:10:44 -0500 [thread overview]
Message-ID: <20180706131044.GA25469@embeddedor.com> (raw)
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 <gustavo@embeddedor.com>
---
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
next reply other threads:[~2018-07-06 13:10 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-06 13:10 Gustavo A. R. Silva [this message]
2018-07-06 14:11 ` [PATCH] xarray: Fix lock/unlock imbalance in xa_alloc Matthew Wilcox
2018-07-06 14:13 ` Gustavo A. R. Silva
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180706131044.GA25469@embeddedor.com \
--to=gustavo@embeddedor.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).