Message ID | 20241019023716.4516-4-richard.weiyang@gmail.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | refine storing NULL | expand |
* Wei Yang <richard.weiyang@gmail.com> [241018 22:37]: > Before calling mas_new_root(), the range has been checked. > > Signed-off-by: Wei Yang <richard.weiyang@gmail.com> > CC: Liam R. Howlett <Liam.Howlett@Oracle.com> > CC: Sidhartha Kumar <sidhartha.kumar@oracle.com> > CC: Lorenzo Stoakes <lorenzo.stoakes@oracle.com> > Reviewed-by: Liam R. Howlett <Liam.Howlett@Oracle.com> > --- > v4: add WARN_ON_ONCE() to check mis-usage. > --- > lib/maple_tree.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/lib/maple_tree.c b/lib/maple_tree.c > index 517ddf2950e6..2226e77c00cb 100644 > --- a/lib/maple_tree.c > +++ b/lib/maple_tree.c > @@ -3662,7 +3662,9 @@ static inline void mas_new_root(struct ma_state *mas, void *entry) > void __rcu **slots; > unsigned long *pivots; > > - if (!entry && !mas->index && mas->last == ULONG_MAX) { > + WARN_ON_ONCE(mas->index || mas->last != ULONG_MAX); > + > + if (!entry) { > mas->depth = 0; > mas_set_height(mas); > rcu_assign_pointer(mas->tree->ma_root, entry); > -- > 2.34.1 >
diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 517ddf2950e6..2226e77c00cb 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -3662,7 +3662,9 @@ static inline void mas_new_root(struct ma_state *mas, void *entry) void __rcu **slots; unsigned long *pivots; - if (!entry && !mas->index && mas->last == ULONG_MAX) { + WARN_ON_ONCE(mas->index || mas->last != ULONG_MAX); + + if (!entry) { mas->depth = 0; mas_set_height(mas); rcu_assign_pointer(mas->tree->ma_root, entry);
Before calling mas_new_root(), the range has been checked. Signed-off-by: Wei Yang <richard.weiyang@gmail.com> CC: Liam R. Howlett <Liam.Howlett@Oracle.com> CC: Sidhartha Kumar <sidhartha.kumar@oracle.com> CC: Lorenzo Stoakes <lorenzo.stoakes@oracle.com> --- v4: add WARN_ON_ONCE() to check mis-usage. --- lib/maple_tree.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)