bcachefs: Fix locking in bch2_ioc_setlabel()
authorKent Overstreet <kent.overstreet@linux.dev>
Tue, 20 Aug 2024 23:31:20 +0000 (19:31 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Thu, 22 Aug 2024 06:07:23 +0000 (02:07 -0400)
Fixes: 7a254053a590 ("bcachefs: support FS_IOC_SETFSLABEL")
Reported-by: syzbot+7e9efdfec27fbde0141d@syzkaller.appspotmail.com
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/fs-ioctl.c

index aea8132..99c7fe9 100644 (file)
@@ -328,9 +328,8 @@ static int bch2_ioc_setlabel(struct bch_fs *c,
 
        mutex_lock(&c->sb_lock);
        strscpy(c->disk_sb.sb->label, label, BCH_SB_LABEL_SIZE);
-       mutex_unlock(&c->sb_lock);
-
        ret = bch2_write_super(c);
+       mutex_unlock(&c->sb_lock);
 
        mnt_drop_write_file(file);
        return ret;