Currently if a mounted-btrfs instance is mounted for the 2nd time without first unmounting the first instance then we hit a memory leak in btrfs_mount_root due to the fs_info of the acquired superblock is different than the newly allocated fs info. Fix this by specifically checking if the fs_info instance of the newly acquired superblock is the same as ours and free it if not.
Reproducer: mount /dev/vdc /media/scratch mount /dev/vdc /media/scratch2 <- memory leak hit Signed-off-by: Nikolay Borisov <nbori...@suse.com> --- fs/btrfs/super.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index e57eb6e70278..ea3bca85be44 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -1612,7 +1612,11 @@ static struct dentry *btrfs_mount_root(struct file_system_type *fs_type, goto error_sec_opts; } - fs_info = btrfs_sb(s); + if (btrfs_sb(s) != fs_info) { + free_fs_info(fs_info); + fs_info = btrfs_sb(s); + } + error = setup_security_options(fs_info, s, &new_sec_opts); if (error) { deactivate_locked_super(s); -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html