[PATCH] fuse: replace BUG_ON with WARN_ON and -EBUSY in fuse_ctl_fill_super

Yuto Ohnuki posted 1 patch 1 month, 3 weeks ago
fs/fuse/control.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
[PATCH] fuse: replace BUG_ON with WARN_ON and -EBUSY in fuse_ctl_fill_super
Posted by Yuto Ohnuki 1 month, 3 weeks ago
Replace BUG_ON(fuse_control_sb) with WARN_ON() that returns -EBUSY.

Currently get_tree_single() prevents duplicate calls to
fuse_ctl_fill_super(), making this condition unreachable in practice.
However, BUG_ON() should not be used for conditions that can be handled
gracefully. Use WARN_ON() to log the unexpected state instead of
crashing.

Signed-off-by: Yuto Ohnuki <ytohnuki@amazon.com>
---
 fs/fuse/control.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/fs/fuse/control.c b/fs/fuse/control.c
index 140bd5730d99..8bac837fd4e1 100644
--- a/fs/fuse/control.c
+++ b/fs/fuse/control.c
@@ -316,7 +316,11 @@ static int fuse_ctl_fill_super(struct super_block *sb, struct fs_context *fsc)
 		return err;
 
 	mutex_lock(&fuse_mutex);
-	BUG_ON(fuse_control_sb);
+	if (WARN_ON(fuse_control_sb)) {
+		mutex_unlock(&fuse_mutex);
+		return -EBUSY;
+	}
+
 	fuse_control_sb = sb;
 	list_for_each_entry(fc, &fuse_conn_list, entry) {
 		err = fuse_ctl_add_conn(fc);
-- 
2.50.1




Amazon Web Services EMEA SARL, 38 avenue John F. Kennedy, L-1855 Luxembourg, R.C.S. Luxembourg B186284

Amazon Web Services EMEA SARL, Irish Branch, One Burlington Plaza, Burlington Road, Dublin 4, Ireland, branch registration number 908705
Re: [PATCH] fuse: replace BUG_ON with WARN_ON and -EBUSY in fuse_ctl_fill_super
Posted by Miklos Szeredi 1 month, 2 weeks ago
On Tue, 24 Feb 2026 at 12:56, Yuto Ohnuki <ytohnuki@amazon.com> wrote:
>
> Replace BUG_ON(fuse_control_sb) with WARN_ON() that returns -EBUSY.
>
> Currently get_tree_single() prevents duplicate calls to
> fuse_ctl_fill_super(), making this condition unreachable in practice.
> However, BUG_ON() should not be used for conditions that can be handled
> gracefully. Use WARN_ON() to log the unexpected state instead of
> crashing.

NAK, I don't want to add complexity where it has zero benefit.

Thanks,
Miklos