mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-10 07:00:48 +00:00
video: fbdev: imxfb: Convert request_mem_region + ioremap to devm_ioremap_resource
This has several advantages: - No need for manual undo of the two functions in the error path and the remove function. - Drops error handling in .remove() Note that returning early in .remove() yields resource leaks that often result in access of freed memory or unmapped registers later. - Fixes a resource leak request_mem_region allocates memory for the returned pointer that was never freed. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Helge Deller <deller@gmx.de>
This commit is contained in:
parent
ded77a74ee
commit
b083c22d51
@ -937,13 +937,6 @@ static int imxfb_probe(struct platform_device *pdev)
|
||||
info->fix.smem_len = max_t(size_t, info->fix.smem_len,
|
||||
m->mode.xres * m->mode.yres * bytes_per_pixel);
|
||||
|
||||
res = request_mem_region(res->start, resource_size(res),
|
||||
DRIVER_NAME);
|
||||
if (!res) {
|
||||
ret = -EBUSY;
|
||||
goto failed_req;
|
||||
}
|
||||
|
||||
fbi->clk_ipg = devm_clk_get(&pdev->dev, "ipg");
|
||||
if (IS_ERR(fbi->clk_ipg)) {
|
||||
ret = PTR_ERR(fbi->clk_ipg);
|
||||
@ -977,7 +970,7 @@ static int imxfb_probe(struct platform_device *pdev)
|
||||
goto failed_getclock;
|
||||
}
|
||||
|
||||
fbi->regs = ioremap(res->start, resource_size(res));
|
||||
fbi->regs = devm_ioremap_resource(&pdev->dev, res);
|
||||
if (fbi->regs == NULL) {
|
||||
dev_err(&pdev->dev, "Cannot map frame buffer registers\n");
|
||||
ret = -ENOMEM;
|
||||
@ -1049,11 +1042,9 @@ failed_cmap:
|
||||
dma_free_wc(&pdev->dev, fbi->map_size, info->screen_buffer,
|
||||
fbi->map_dma);
|
||||
failed_map:
|
||||
iounmap(fbi->regs);
|
||||
failed_ioremap:
|
||||
failed_getclock:
|
||||
release_mem_region(res->start, resource_size(res));
|
||||
failed_req:
|
||||
failed_of_parse:
|
||||
kfree(info->pseudo_palette);
|
||||
failed_init:
|
||||
@ -1065,11 +1056,6 @@ static int imxfb_remove(struct platform_device *pdev)
|
||||
{
|
||||
struct fb_info *info = platform_get_drvdata(pdev);
|
||||
struct imxfb_info *fbi = info->par;
|
||||
struct resource *res;
|
||||
|
||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||
if (!res)
|
||||
return -EINVAL;
|
||||
|
||||
imxfb_disable_controller(fbi);
|
||||
|
||||
@ -1077,8 +1063,6 @@ static int imxfb_remove(struct platform_device *pdev)
|
||||
fb_dealloc_cmap(&info->cmap);
|
||||
dma_free_wc(&pdev->dev, fbi->map_size, info->screen_buffer,
|
||||
fbi->map_dma);
|
||||
iounmap(fbi->regs);
|
||||
release_mem_region(res->start, resource_size(res));
|
||||
kfree(info->pseudo_palette);
|
||||
framebuffer_release(info);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user