lkml.org 
[lkml]   [2023]   [Jul]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
Subject[PATCH 4/8] fs/ntfs3: Don't allow to change label if volume is read-only
From

Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
---
 fs/ntfs3/super.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c
index d24f2da36bb2..da739e509269 100644
--- a/fs/ntfs3/super.c
+++ b/fs/ntfs3/super.c
@@ -489,7 +489,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;
--
2.34.1

\
 
 \ /
  Last update: 2023-07-03 09:27    [W:0.092 / U:0.164 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site