Skip to content

Commit

Permalink
fs/ntfs3: Fix double free on remount
Browse files Browse the repository at this point in the history
Pointer to options was freed twice on remount
Fixes xfstest generic/361
Fixes: 82cae26 ("fs/ntfs3: Add initialization of super block")

Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
  • Loading branch information
aalexandrovich committed Jun 6, 2022
1 parent b7b6160 commit cd39981
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions fs/ntfs3/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <linux/fs_context.h>
#include <linux/fs_parser.h>
#include <linux/log2.h>
#include <linux/minmax.h>
#include <linux/module.h>
#include <linux/nls.h>
#include <linux/seq_file.h>
Expand Down Expand Up @@ -390,7 +391,7 @@ static int ntfs_fs_reconfigure(struct fs_context *fc)
return -EINVAL;
}

memcpy(sbi->options, new_opts, sizeof(*new_opts));
swap(sbi->options, fc->fs_private);

return 0;
}
Expand Down Expand Up @@ -897,6 +898,8 @@ static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc)
ref.high = 0;

sbi->sb = sb;
sbi->options = fc->fs_private;
fc->fs_private = NULL;
sb->s_flags |= SB_NODIRATIME;
sb->s_magic = 0x7366746e; // "ntfs"
sb->s_op = &ntfs_sops;
Expand Down Expand Up @@ -1260,8 +1263,6 @@ static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc)
goto put_inode_out;
}

fc->fs_private = NULL;

return 0;

put_inode_out:
Expand Down Expand Up @@ -1414,7 +1415,6 @@ static int ntfs_init_fs_context(struct fs_context *fc)
mutex_init(&sbi->compress.mtx_lzx);
#endif

sbi->options = opts;
fc->s_fs_info = sbi;
ok:
fc->fs_private = opts;
Expand Down

0 comments on commit cd39981

Please sign in to comment.