[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241216190113.1226145-2-Liam.Howlett@oracle.com>
Date: Mon, 16 Dec 2024 14:01:12 -0500
From: "Liam R. Howlett" <Liam.Howlett@...cle.com>
To: Andrew Morton <akpm@...ux-foundation.org>
Cc: maple-tree@...ts.infradead.org, linux-mm@...ck.org,
linux-kernel@...r.kernel.org, Yang Erkun <yangerkun@...weicloud.com>,
chuck.lever@...cle.com, brauner@...nel.org,
"Liam R. Howlett" <Liam.Howlett@...cle.com>
Subject: [PATCH 1/2] maple_tree: Fix mas_alloc_cyclic() second search
From: "Liam R. Howlett" <Liam.Howlett@...cle.com>
The first search may leave the maple state in an error state. Reset the
maple state before the second search so that the search has a chance of
executing correctly after an exhausted first search.
Link: https://lore.kernel.org/all/20241216060600.287B4C4CED0@smtp.kernel.org/
Fixes: 9b6713cc7522 ("maple_tree: Add mtree_alloc_cyclic()")
Cc: Yang Erkun <yangerkun@...weicloud.com>
Cc: chuck.lever@...cle.com
Cc: brauner@...nel.org
Signed-off-by: Liam R. Howlett <Liam.Howlett@...cle.com>
---
lib/maple_tree.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/lib/maple_tree.c b/lib/maple_tree.c
index 940d30653407b..f7153ade1be5f 100644
--- a/lib/maple_tree.c
+++ b/lib/maple_tree.c
@@ -4335,7 +4335,6 @@ int mas_alloc_cyclic(struct ma_state *mas, unsigned long *startp,
{
unsigned long min = range_lo;
int ret = 0;
- struct ma_state m = *mas;
range_lo = max(min, *next);
ret = mas_empty_area(mas, range_lo, range_hi, 1);
@@ -4344,7 +4343,7 @@ int mas_alloc_cyclic(struct ma_state *mas, unsigned long *startp,
ret = 1;
}
if (ret < 0 && range_lo > min) {
- *mas = m;
+ mas_reset(mas);
ret = mas_empty_area(mas, min, range_hi, 1);
if (ret == 0)
ret = 1;
--
2.43.0
Powered by blists - more mailing lists