linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] xarray: Fix lock/unlock imbalance in xa_alloc
@ 2018-07-06 13:10 Gustavo A. R. Silva
  2018-07-06 14:11 ` Matthew Wilcox
  0 siblings, 1 reply; 3+ messages in thread
From: Gustavo A. R. Silva @ 2018-07-06 13:10 UTC (permalink / raw)
  To: Matthew Wilcox; +Cc: linux-fsdevel, linux-kernel, Gustavo A. R. Silva

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] xarray: Fix lock/unlock imbalance in xa_alloc
  2018-07-06 13:10 [PATCH] xarray: Fix lock/unlock imbalance in xa_alloc Gustavo A. R. Silva
@ 2018-07-06 14:11 ` Matthew Wilcox
  2018-07-06 14:13   ` Gustavo A. R. Silva
  0 siblings, 1 reply; 3+ messages in thread
From: Matthew Wilcox @ 2018-07-06 14:11 UTC (permalink / raw)
  To: Gustavo A. R. Silva; +Cc: linux-fsdevel, linux-kernel

On Fri, Jul 06, 2018 at 08:10:44AM -0500, Gustavo A. R. Silva wrote:
> Release *xa_lock* before return.

Thank you!  I need to improve the test suite to catch that one.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] xarray: Fix lock/unlock imbalance in xa_alloc
  2018-07-06 14:11 ` Matthew Wilcox
@ 2018-07-06 14:13   ` Gustavo A. R. Silva
  0 siblings, 0 replies; 3+ messages in thread
From: Gustavo A. R. Silva @ 2018-07-06 14:13 UTC (permalink / raw)
  To: Matthew Wilcox; +Cc: linux-fsdevel, linux-kernel



On 07/06/2018 09:11 AM, Matthew Wilcox wrote:
> On Fri, Jul 06, 2018 at 08:10:44AM -0500, Gustavo A. R. Silva wrote:
>> Release *xa_lock* before return.
> 
> Thank you!  I need to improve the test suite to catch that one.
> 

Glad to help. :)

Thanks
--
Gustavo

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-07-06 14:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-06 13:10 [PATCH] xarray: Fix lock/unlock imbalance in xa_alloc Gustavo A. R. Silva
2018-07-06 14:11 ` Matthew Wilcox
2018-07-06 14:13   ` Gustavo A. R. Silva

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).