* [PATCH] ext2: replace BUG_ON with WARN_ON_ONCE in ext2_get_blocks
@ 2026-02-07 1:06 Milos Nikic
2026-02-27 5:08 ` Milos Nikic
0 siblings, 1 reply; 3+ messages in thread
From: Milos Nikic @ 2026-02-07 1:06 UTC (permalink / raw)
To: jack; +Cc: linux-ext4, linux-kernel, Milos Nikic
If ext2_get_blocks() is called with maxblocks == 0, it currently triggers
a BUG_ON(), causing a kernel panic.
While this condition implies a logic error in the caller, a filesystem
should not crash the system due to invalid arguments.
Replace the BUG_ON() with a WARN_ON_ONCE() to provide a stack trace for
debugging, and return -EINVAL to handle the error gracefully.
Signed-off-by: Milos Nikic <nikic.milos@gmail.com>
---
fs/ext2/inode.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c
index dbfe9098a124..18bf1a91dbc2 100644
--- a/fs/ext2/inode.c
+++ b/fs/ext2/inode.c
@@ -638,7 +638,8 @@ static int ext2_get_blocks(struct inode *inode,
int count = 0;
ext2_fsblk_t first_block = 0;
- BUG_ON(maxblocks == 0);
+ if (WARN_ON_ONCE(maxblocks == 0))
+ return -EINVAL;
depth = ext2_block_to_path(inode,iblock,offsets,&blocks_to_boundary);
--
2.52.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ext2: replace BUG_ON with WARN_ON_ONCE in ext2_get_blocks
2026-02-07 1:06 [PATCH] ext2: replace BUG_ON with WARN_ON_ONCE in ext2_get_blocks Milos Nikic
@ 2026-02-27 5:08 ` Milos Nikic
2026-02-27 11:16 ` Jan Kara
0 siblings, 1 reply; 3+ messages in thread
From: Milos Nikic @ 2026-02-27 5:08 UTC (permalink / raw)
To: nikic.milos; +Cc: jack, linux-ext4, linux-kernel
Hi Jan,
Just a friendly ping on this patch now that a few weeks have passed.
Let me know if you need any changes!
Thanks,
Milos
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ext2: replace BUG_ON with WARN_ON_ONCE in ext2_get_blocks
2026-02-27 5:08 ` Milos Nikic
@ 2026-02-27 11:16 ` Jan Kara
0 siblings, 0 replies; 3+ messages in thread
From: Jan Kara @ 2026-02-27 11:16 UTC (permalink / raw)
To: Milos Nikic; +Cc: jack, linux-ext4, linux-kernel
On Thu 26-02-26 21:08:19, Milos Nikic wrote:
> Hi Jan,
>
> Just a friendly ping on this patch now that a few weeks have passed.
> Let me know if you need any changes!
Thanks merged now.
Honza
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-02-27 11:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-02-07 1:06 [PATCH] ext2: replace BUG_ON with WARN_ON_ONCE in ext2_get_blocks Milos Nikic
2026-02-27 5:08 ` Milos Nikic
2026-02-27 11:16 ` Jan Kara
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®