From: Konstantin Komarov Date: Mon, 25 Sep 2023 07:56:15 +0000 (+0300) Subject: fs/ntfs3: Do not allow to change label if volume is read-only X-Git-Tag: v6.6-rc7~33^2~7 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e52dce610a2d53bf2b5e94a8843c71cb73a91ea5;p=thirdparty%2Fkernel%2Flinux.git fs/ntfs3: Do not allow to change label if volume is read-only Signed-off-by: Konstantin Komarov --- diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c index 5811da7e9d458..cf0a720523f05 100644 --- a/fs/ntfs3/super.c +++ b/fs/ntfs3/super.c @@ -497,7 +497,12 @@ static ssize_t ntfs3_label_write(struct file *file, const char __user *buffer, int err; struct super_block *sb = pde_data(file_inode(file)); ssize_t ret = count; - u8 *label = kmalloc(count, GFP_NOFS); + u8 *label; + + if (sb_rdonly(sb)) + return -EROFS; + + label = kmalloc(count, GFP_NOFS); if (!label) return -ENOMEM;