Skip to content

Commit 532b618

Browse files
ebiedermkdave
authored andcommitted
btrfs: On error always free subvol_name in btrfs_mount
The subvol_name is allocated in btrfs_parse_subvol_options and is consumed and freed in mount_subvol. Add a free to the error paths that don't call mount_subvol so that it is guaranteed that subvol_name is freed when an error happens. Fixes: 312c89f ("btrfs: cleanup btrfs_mount() using btrfs_mount_root()") Cc: stable@vger.kernel.org # v4.19+ Reviewed-by: Nikolay Borisov <nborisov@suse.com> Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent c7cc64a commit 532b618

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

fs/btrfs/super.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1677,6 +1677,7 @@ static struct dentry *btrfs_mount(struct file_system_type *fs_type, int flags,
16771677
flags | SB_RDONLY, device_name, data);
16781678
if (IS_ERR(mnt_root)) {
16791679
root = ERR_CAST(mnt_root);
1680+
kfree(subvol_name);
16801681
goto out;
16811682
}
16821683

@@ -1686,12 +1687,14 @@ static struct dentry *btrfs_mount(struct file_system_type *fs_type, int flags,
16861687
if (error < 0) {
16871688
root = ERR_PTR(error);
16881689
mntput(mnt_root);
1690+
kfree(subvol_name);
16891691
goto out;
16901692
}
16911693
}
16921694
}
16931695
if (IS_ERR(mnt_root)) {
16941696
root = ERR_CAST(mnt_root);
1697+
kfree(subvol_name);
16951698
goto out;
16961699
}
16971700

0 commit comments

Comments
 (0)