diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c index d011b69ae8ae7b..a165bc257d2237 100644 --- a/fs/ext4/ioctl.c +++ b/fs/ext4/ioctl.c @@ -548,9 +548,17 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) } case EXT4_IOC_SWAP_BOOT: + { + int err; if (!(filp->f_mode & FMODE_WRITE)) return -EBADF; - return swap_inode_boot_loader(sb, inode); + err = mnt_want_write_file(filp); + if (err) + return err; + err = swap_inode_boot_loader(sb, inode); + mnt_drop_write_file(filp); + return err; + } case EXT4_IOC_RESIZE_FS: { ext4_fsblk_t n_blocks_count;