Skip to contentSkip to conversation

fuse: replace BUG_ON with WARN_ON and -EBUSY in fuse_ctl_fill_super

PATCH NAK Yuto Ohnuki 2 participants 2 messages Feb 24 – Mar 2

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fuse: replace BUG_ON with WARN_ON and -EBUSY in fuse_ctl_fill_super

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.

---
 fs/fuse/control.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
fs/fuse/control.c +5 -1
index 140bd5730d99..8bac837fd4e1 100644
@@ -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);
Signature · 8 lines
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
maintainer NAK
#1 lore raw
Quoted 8 lines · Yuto Ohnuki

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