提交 d58ab5cf 编写于 作者: A Atsushi Nemoto 提交者: Linus Torvalds

mtd: physmap: fix NULL pointer dereference in error path

commit e480814f ("[MTD] [MAPS] physmap:
fix wrong free and del_mtd_{partition,device}") introduces a NULL pointer
dereference in physmap_flash_remove when called from the error path in
physmap_flash_probe (if map_probe failed).

Call del_mtd_{partition,device} only if info->cmtd was not NULL.
Reported-by: NpHilipp Zabel <philipp.zabel@gmail.com>
Signed-off-by: NAtsushi Nemoto <anemo@mba.ocn.ne.jp>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: "Rafael J. Wysocki" <rjw@sisk.pl>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 9c1e8a4e
......@@ -46,16 +46,19 @@ static int physmap_flash_remove(struct platform_device *dev)
physmap_data = dev->dev.platform_data;
if (info->cmtd) {
#ifdef CONFIG_MTD_PARTITIONS
if (info->nr_parts) {
del_mtd_partitions(info->cmtd);
kfree(info->parts);
} else if (physmap_data->nr_parts)
del_mtd_partitions(info->cmtd);
else
del_mtd_device(info->cmtd);
if (info->nr_parts || physmap_data->nr_parts)
del_mtd_partitions(info->cmtd);
else
del_mtd_device(info->cmtd);
#else
del_mtd_device(info->cmtd);
del_mtd_device(info->cmtd);
#endif
}
#ifdef CONFIG_MTD_PARTITIONS
if (info->nr_parts)
kfree(info->parts);
#endif
#ifdef CONFIG_MTD_CONCAT
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册