summaryrefslogtreecommitdiff
path: root/drivers/video/fbdev/imxfb.c
diff options
context:
space:
mode:
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>2022-07-23 20:57:20 +0300
committerHelge Deller <deller@gmx.de>2022-07-26 10:16:38 +0300
commitb083c22d51148f3d3028291343196471be5d9f36 (patch)
tree0c74048b7978901939d93d44ec63d25b0ab4f012 /drivers/video/fbdev/imxfb.c
parentded77a74ee6bc3dea72ad41129823a812e4b64f3 (diff)
downloadlinux-b083c22d51148f3d3028291343196471be5d9f36.tar.xz
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>
Diffstat (limited to 'drivers/video/fbdev/imxfb.c')
-rw-r--r--drivers/video/fbdev/imxfb.c18
1 files changed, 1 insertions, 17 deletions
diff --git a/drivers/video/fbdev/imxfb.c b/drivers/video/fbdev/imxfb.c
index fa6a19c1ae9b..c48477893dd0 100644
--- a/drivers/video/fbdev/imxfb.c
+++ b/drivers/video/fbdev/imxfb.c
@@ -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);