summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorYi Zeng <yi.zeng@amlogic.com>2018-04-03 11:39:13 +0800
committerXiaobo Gu <xiaobo.gu@amlogic.com>2018-04-18 23:52:21 -0700
commite3e5aa0aefa2c72056fa3812cae37b5ef235cdcf (patch)
treeeec24e2041b47d78b49571bd9eb4771da245618e /fs
parent8e89779e125b203371cfc6d46cf91c9b377c5f45 (diff)
downloadu-boot-odroid-c1-e3e5aa0aefa2c72056fa3812cae37b5ef235cdcf.tar.gz
ubi: repair some logic weak in ubi[1/1]
PD#163797: some duplicate free the global pointer and missed to free the malloc buffer in some functions. 1.set the global pointer to NULL after free 2.free some missed buffer in end of the functions Change-Id: I032ffd6f03765dd3de608c705f842e0e0b2f9395 Signed-off-by: Yi Zeng <yi.zeng@amlogic.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/ubifs/super.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
index 01d449a7af..af7c42a44f 100644
--- a/fs/ubifs/super.c
+++ b/fs/ubifs/super.c
@@ -1751,7 +1751,9 @@ void ubifs_umount(struct ubifs_info *c)
/* Finally free U-Boot's global copy of superblock */
if (ubifs_sb != NULL) {
free(ubifs_sb->s_fs_info);
+ ubifs_sb->s_fs_info = NULL;
free(ubifs_sb);
+ ubifs_sb = NULL;
}
#endif
}
@@ -2443,7 +2445,7 @@ static struct dentry *ubifs_mount(struct file_system_type *fs_type, int flags,
{
struct ubi_volume_desc *ubi;
struct ubifs_info *c;
- struct super_block *sb;
+ struct super_block *sb = NULL;
int err;
dbg_gen("name %s, flags %#x", name, flags);
@@ -2471,6 +2473,7 @@ static struct dentry *ubifs_mount(struct file_system_type *fs_type, int flags,
sb = sget(fs_type, sb_test, sb_set, flags, c);
if (IS_ERR(sb)) {
err = PTR_ERR(sb);
+ sb = NULL;
kfree(c);
goto out_close;
}
@@ -2486,8 +2489,10 @@ static struct dentry *ubifs_mount(struct file_system_type *fs_type, int flags,
}
} else {
err = ubifs_fill_super(sb, data, flags & MS_SILENT ? 1 : 0);
- if (err)
+ if (err) {
+ kfree(c);
goto out_deact;
+ }
/* We do not support atime */
sb->s_flags |= MS_ACTIVE | MS_NOATIME;
}
@@ -2507,6 +2512,7 @@ out_deact:
deactivate_locked_super(sb);
#endif
out_close:
+ kfree(sb);
ubi_close_volume(ubi);
return ERR_PTR(err);
}