ANDROID: mnt: Fix freeing of mount data

Fix double free on error paths

Signed-off-by: Daniel Rosenberg <drosen@google.com>
Change-Id: I1c25a175e87e5dd5cafcdcf9d78bf4c0dc3f88ef
Bug: 65386954
Fixes: aa6d3ace42f9 ("mnt: Add filesystem private data to mount points")
Signed-off-by: Kevin F. Haggerty <haggertk@lineageos.org>
This commit is contained in:
Daniel Rosenberg 2017-09-06 13:06:43 -07:00 committed by Francescodario Cuzzocrea
parent 29c5bde441
commit c6363122f6
1 changed files with 1 additions and 3 deletions

View File

@ -186,6 +186,7 @@ static struct mount *alloc_vfsmnt(const char *name)
mnt->mnt_count = 1;
mnt->mnt_writers = 0;
#endif
mnt->mnt.data = NULL;
INIT_LIST_HEAD(&mnt->mnt_hash);
INIT_LIST_HEAD(&mnt->mnt_child);
@ -699,7 +700,6 @@ vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void
if (!mnt)
return ERR_PTR(-ENOMEM);
mnt->mnt.data = NULL;
if (type->alloc_mnt_data) {
mnt->mnt.data = type->alloc_mnt_data();
if (!mnt->mnt.data) {
@ -713,7 +713,6 @@ vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void
root = mount_fs(type, flags, name, &mnt->mnt, data);
if (IS_ERR(root)) {
kfree(mnt->mnt.data);
free_vfsmnt(mnt);
return ERR_CAST(root);
}
@ -792,7 +791,6 @@ static struct mount *clone_mnt(struct mount *old, struct dentry *root,
return mnt;
out_free:
kfree(mnt->mnt.data);
free_vfsmnt(mnt);
return ERR_PTR(err);
}