提交 2050f67f 编写于 作者: B Baokun Li 提交者: Zheng Zengkai

jffs2: fix NULL pointer dereference in jffs2_scan_medium

hulk inclusion
category: bugfix
bugzilla: 185988, https://gitee.com/openeuler/kernel/issues/I4YVV3

--------------------------------

In jffs2_scan_medium,
if `s = kzalloc(sizeof(struct jffs2_summary), GFP_KERNEL);` returns error,
go to "out" to do clear. Null pointer dereference occurs when
`if (s->sum_list_head)` is executed in "out".

Fixes: bf7ba557361f ("[Huawei] jffs2: fix memory leak in jffs2_scan_medium")
Signed-off-by: NBaokun Li <libaokun1@huawei.com>
Reviewed-by: NZhang Yi <yi.zhang@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 80431881
......@@ -136,7 +136,7 @@ int jffs2_scan_medium(struct jffs2_sb_info *c)
if (!s) {
JFFS2_WARNING("Can't allocate memory for summary\n");
ret = -ENOMEM;
goto out;
goto out_buf;
}
}
......@@ -275,15 +275,15 @@ int jffs2_scan_medium(struct jffs2_sb_info *c)
}
ret = 0;
out:
jffs2_sum_reset_collected(s);
kfree(s);
out_buf:
if (buf_size)
kfree(flashbuf);
#ifndef __ECOS
else
mtd_unpoint(c->mtd, 0, c->mtd->size);
#endif
if (s->sum_list_head)
jffs2_sum_reset_collected(s);
kfree(s);
return ret;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册