mirror of https://gitee.com/openkylin/linux.git
mtd: physmap_of: Release resources on error
During probe, if there was an error the memory region and the memory map were not properly released.This can lead a system unusable if deferred probe is in use. Replace mem_request and map with devm_ioremap_resource Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com> Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
This commit is contained in:
parent
e42e175ae3
commit
ef0de747f7
|
@ -31,7 +31,6 @@
|
||||||
struct of_flash_list {
|
struct of_flash_list {
|
||||||
struct mtd_info *mtd;
|
struct mtd_info *mtd;
|
||||||
struct map_info map;
|
struct map_info map;
|
||||||
struct resource *res;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct of_flash {
|
struct of_flash {
|
||||||
|
@ -56,18 +55,10 @@ static int of_flash_remove(struct platform_device *dev)
|
||||||
mtd_concat_destroy(info->cmtd);
|
mtd_concat_destroy(info->cmtd);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < info->list_size; i++) {
|
for (i = 0; i < info->list_size; i++)
|
||||||
if (info->list[i].mtd)
|
if (info->list[i].mtd)
|
||||||
map_destroy(info->list[i].mtd);
|
map_destroy(info->list[i].mtd);
|
||||||
|
|
||||||
if (info->list[i].map.virt)
|
|
||||||
iounmap(info->list[i].map.virt);
|
|
||||||
|
|
||||||
if (info->list[i].res) {
|
|
||||||
release_resource(info->list[i].res);
|
|
||||||
kfree(info->list[i].res);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,10 +206,11 @@ static int of_flash_probe(struct platform_device *dev)
|
||||||
|
|
||||||
err = -EBUSY;
|
err = -EBUSY;
|
||||||
res_size = resource_size(&res);
|
res_size = resource_size(&res);
|
||||||
info->list[i].res = request_mem_region(res.start, res_size,
|
info->list[i].map.virt = devm_ioremap_resource(&dev->dev, &res);
|
||||||
dev_name(&dev->dev));
|
if (IS_ERR(info->list[i].map.virt)) {
|
||||||
if (!info->list[i].res)
|
err = PTR_ERR(info->list[i].map.virt);
|
||||||
goto err_out;
|
goto err_out;
|
||||||
|
}
|
||||||
|
|
||||||
err = -ENXIO;
|
err = -ENXIO;
|
||||||
width = of_get_property(dp, "bank-width", NULL);
|
width = of_get_property(dp, "bank-width", NULL);
|
||||||
|
@ -246,15 +238,6 @@ static int of_flash_probe(struct platform_device *dev)
|
||||||
if (err)
|
if (err)
|
||||||
goto err_out;
|
goto err_out;
|
||||||
|
|
||||||
err = -ENOMEM;
|
|
||||||
info->list[i].map.virt = ioremap(info->list[i].map.phys,
|
|
||||||
info->list[i].map.size);
|
|
||||||
if (!info->list[i].map.virt) {
|
|
||||||
dev_err(&dev->dev, "Failed to ioremap() flash"
|
|
||||||
" region\n");
|
|
||||||
goto err_out;
|
|
||||||
}
|
|
||||||
|
|
||||||
simple_map_init(&info->list[i].map);
|
simple_map_init(&info->list[i].map);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in New Issue