]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
fs/ntfs3: Do not allow to change label if volume is read-only
authorKonstantin Komarov <almaz.alexandrovich@paragon-software.com>
Mon, 25 Sep 2023 07:56:15 +0000 (10:56 +0300)
committerKonstantin Komarov <almaz.alexandrovich@paragon-software.com>
Thu, 28 Sep 2023 12:04:02 +0000 (15:04 +0300)
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
fs/ntfs3/super.c

index 5811da7e9d458e141f07272588d913ed330f6f6f..cf0a720523f058e09e3b2255225cf6af66e056dc 100644 (file)
@@ -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;