fuse: replace BUG_ON with WARN_ON and -EBUSY in fuse_ctl_fill_super
Subsystems (2)
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
@@ -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
Quoted 8 lines · Yuto Ohnuki
Replace
BUG_ON(fuse_control_sb)withWARN_ON()that returns-EBUSY.Currently
get_tree_single()prevents duplicate calls tofuse_ctl_fill_super(), making this condition unreachable in practice. However,BUG_ON()should not be used for conditions that can be handled gracefully. UseWARN_ON()to log the unexpected state instead of crashing.
NAK, I don't want to add complexity where it has zero benefit.
Thanks,
Miklos