diff mbox series

maple_tree: Remove a BUG_ON() in mas_alloc_nodes()

Message ID 20250213114453.1078318-1-ptesarik@suse.com (mailing list archive)
State New
Headers show
Series maple_tree: Remove a BUG_ON() in mas_alloc_nodes() | expand

Commit Message

Petr Tesarik Feb. 13, 2025, 11:44 a.m. UTC
Remove a BUG_ON() right before a WARN_ON() with the same condition.

Calling WARN_ON() and BUG_ON() here is definitely wrong.  Since the goal is
generally to remove BUG_ON() invocations from the kernel, keep only the
WARN_ON().

Fixes: 067311d33e65 ("maple_tree: separate ma_state node from status")
Signed-off-by: Petr Tesarik <ptesarik@suse.com>
---
 lib/maple_tree.c | 1 -
 1 file changed, 1 deletion(-)

Comments

Liam R. Howlett Feb. 13, 2025, 7:37 p.m. UTC | #1
* Petr Tesarik <ptesarik@suse.com> [250213 06:45]:
> Remove a BUG_ON() right before a WARN_ON() with the same condition.
> 
> Calling WARN_ON() and BUG_ON() here is definitely wrong.  Since the goal is
> generally to remove BUG_ON() invocations from the kernel, keep only the
> WARN_ON().

Sure.. but this isn't going to have the end result of not crashing.  We
ran out of allocations so we will very quickly be dereferencing NULL.

Care has been taken to avoid this from happening, so I'm fine with
either as this comes up in testing only.  In fact, I probably added this
during the testing and it slipped through.  Thanks for finding it.

> 
> Fixes: 067311d33e65 ("maple_tree: separate ma_state node from status")
> Signed-off-by: Petr Tesarik <ptesarik@suse.com>

Reviewed-by: Liam R. Howlett <Liam.Howlett@Oracle.com>


> ---
>  lib/maple_tree.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/lib/maple_tree.c b/lib/maple_tree.c
> index f7153ade1be5..0f2111d436c4 100644
> --- a/lib/maple_tree.c
> +++ b/lib/maple_tree.c
> @@ -1245,7 +1245,6 @@ static inline void mas_alloc_nodes(struct ma_state *mas, gfp_t gfp)
>  	if (mas->mas_flags & MA_STATE_PREALLOC) {
>  		if (allocated)
>  			return;
> -		BUG_ON(!allocated);
>  		WARN_ON(!allocated);
>  	}
>  
> -- 
> 2.48.1
>
diff mbox series

Patch

diff --git a/lib/maple_tree.c b/lib/maple_tree.c
index f7153ade1be5..0f2111d436c4 100644
--- a/lib/maple_tree.c
+++ b/lib/maple_tree.c
@@ -1245,7 +1245,6 @@  static inline void mas_alloc_nodes(struct ma_state *mas, gfp_t gfp)
 	if (mas->mas_flags & MA_STATE_PREALLOC) {
 		if (allocated)
 			return;
-		BUG_ON(!allocated);
 		WARN_ON(!allocated);
 	}