summaryrefslogtreecommitdiffstats
path: root/fs/ntfs3
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2023-08-10 00:05:45 +0200
committerChristian Brauner <brauner@kernel.org>2023-08-10 10:34:56 +0200
commita4f64a300a299f884a1da55d99c97a87061201cd (patch)
tree249f9254282dacabba37c2e355065fed9298b91b /fs/ntfs3
parentntfs3: don't call sync_blockdev in ntfs_put_super (diff)
downloadlinux-a4f64a300a299f884a1da55d99c97a87061201cd.tar.xz
linux-a4f64a300a299f884a1da55d99c97a87061201cd.zip
ntfs3: free the sbi in ->kill_sb
As a rule of thumb everything allocated to the fs_context and moved into the super_block should be freed by ->kill_sb so that the teardown handling doesn't need to be duplicated between the fill_super error path and put_super. Implement an ntfs3-specific kill_sb method to do that. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Christian Brauner <brauner@kernel.org> Message-Id: <20230809220545.1308228-14-hch@lst.de> Signed-off-by: Christian Brauner <brauner@kernel.org>
Diffstat (limited to 'fs/ntfs3')
-rw-r--r--fs/ntfs3/super.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c
index 727138933a93..5fffddea554f 100644
--- a/fs/ntfs3/super.c
+++ b/fs/ntfs3/super.c
@@ -625,10 +625,6 @@ static void ntfs_put_super(struct super_block *sb)
/* Mark rw ntfs as clear, if possible. */
ntfs_set_state(sbi, NTFS_DIRTY_CLEAR);
-
- put_mount_options(sbi->options);
- ntfs3_free_sbi(sbi);
- sb->s_fs_info = NULL;
}
static int ntfs_statfs(struct dentry *dentry, struct kstatfs *buf)
@@ -1562,15 +1558,7 @@ load_root:
put_inode_out:
iput(inode);
out:
- /*
- * Free resources here.
- * ntfs_fs_free will be called with fc->s_fs_info = NULL
- */
- put_mount_options(sbi->options);
- ntfs3_free_sbi(sbi);
- sb->s_fs_info = NULL;
kfree(boot2);
-
return err;
}
@@ -1726,13 +1714,24 @@ free_opts:
return -ENOMEM;
}
+static void ntfs3_kill_sb(struct super_block *sb)
+{
+ struct ntfs_sb_info *sbi = sb->s_fs_info;
+
+ kill_block_super(sb);
+
+ if (sbi->options)
+ put_mount_options(sbi->options);
+ ntfs3_free_sbi(sbi);
+}
+
// clang-format off
static struct file_system_type ntfs_fs_type = {
.owner = THIS_MODULE,
.name = "ntfs3",
.init_fs_context = ntfs_init_fs_context,
.parameters = ntfs_fs_parameters,
- .kill_sb = kill_block_super,
+ .kill_sb = ntfs3_kill_sb,
.fs_flags = FS_REQUIRES_DEV | FS_ALLOW_IDMAP,
};
// clang-format on