[PATCH] fs/ntfs3: reject remove procdir if create failure

From: Edward Adam Davis

Date: Thu Nov 26 2026 - 06:03:39 EST


"volinfo" and "label" without checking whether proc_create_data() return
NULL in ntfs_create_procdir() and set sbi->procdir = e, potentially
hitting a warning in remove_proc_entry() for remove the label dir entry.

Add a check for label and volinfo when create the proc dir entry.

Fixes: 7832e123490a ("fs/ntfs3: Add support /proc/fs/ntfs3/<dev>/volinfo and /proc/fs/ntfs3/<dev>/label")
Reported-by: syzbot+d7aeb9ab7b1cc022914e@xxxxxxxxxxxxxxxxxxxxxxxxx
Closes: https://syzkaller.appspot.com/bug?extid=d7aeb9ab7b1cc022914e
Signed-off-by: Edward Adam Davis <eadavis@xxxxxxxx>
---
fs/ntfs3/super.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c
index 29aabdc8a801..ce7f9b776b22 100644
--- a/fs/ntfs3/super.c
+++ b/fs/ntfs3/super.c
@@ -634,10 +634,19 @@ static void ntfs_create_procdir(struct super_block *sb)
if (e) {
struct ntfs_sb_info *sbi = sb->s_fs_info;

- proc_create_data("volinfo", 0444, e, &ntfs3_volinfo_fops, sb);
- proc_create_data("label", 0644, e, &ntfs3_label_fops, sb);
+ if (!proc_create_data("volinfo", 0444, e,
+ &ntfs3_volinfo_fops, sb))
+ goto out;
+
+ if (!proc_create_data("label", 0644, e, &ntfs3_label_fops, sb))
+ goto out;
+
sbi->procdir = e;
}
+
+out:
+ remove_proc_entry(sb->s_id, proc_info_root);
+ return;
}

static void ntfs_remove_procdir(struct super_block *sb)
--
2.43.0