Commit 46ac2956 authored by Dan Carpenter's avatar Dan Carpenter Committed by Tomi Valkeinen

video: vt8500: fix error handling in probe()

We shouldn't kfree(fbi) because that was allocated with devm_kzalloc().
There were several error paths which returned directly instead of
releasing resources.
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarTomi Valkeinen <tomi.valkeinen@ti.com>
parent 5a0973f3
...@@ -293,8 +293,7 @@ static int vt8500lcd_probe(struct platform_device *pdev) ...@@ -293,8 +293,7 @@ static int vt8500lcd_probe(struct platform_device *pdev)
+ sizeof(u32) * 16, GFP_KERNEL); + sizeof(u32) * 16, GFP_KERNEL);
if (!fbi) { if (!fbi) {
dev_err(&pdev->dev, "Failed to initialize framebuffer device\n"); dev_err(&pdev->dev, "Failed to initialize framebuffer device\n");
ret = -ENOMEM; return -ENOMEM;
goto failed;
} }
strcpy(fbi->fb.fix.id, "VT8500 LCD"); strcpy(fbi->fb.fix.id, "VT8500 LCD");
...@@ -327,15 +326,13 @@ static int vt8500lcd_probe(struct platform_device *pdev) ...@@ -327,15 +326,13 @@ static int vt8500lcd_probe(struct platform_device *pdev)
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (res == NULL) { if (res == NULL) {
dev_err(&pdev->dev, "no I/O memory resource defined\n"); dev_err(&pdev->dev, "no I/O memory resource defined\n");
ret = -ENODEV; return -ENODEV;
goto failed_fbi;
} }
res = request_mem_region(res->start, resource_size(res), "vt8500lcd"); res = request_mem_region(res->start, resource_size(res), "vt8500lcd");
if (res == NULL) { if (res == NULL) {
dev_err(&pdev->dev, "failed to request I/O memory\n"); dev_err(&pdev->dev, "failed to request I/O memory\n");
ret = -EBUSY; return -EBUSY;
goto failed_fbi;
} }
fbi->regbase = ioremap(res->start, resource_size(res)); fbi->regbase = ioremap(res->start, resource_size(res));
...@@ -346,17 +343,19 @@ static int vt8500lcd_probe(struct platform_device *pdev) ...@@ -346,17 +343,19 @@ static int vt8500lcd_probe(struct platform_device *pdev)
} }
disp_timing = of_get_display_timings(pdev->dev.of_node); disp_timing = of_get_display_timings(pdev->dev.of_node);
if (!disp_timing) if (!disp_timing) {
return -EINVAL; ret = -EINVAL;
goto failed_free_io;
}
ret = of_get_fb_videomode(pdev->dev.of_node, &of_mode, ret = of_get_fb_videomode(pdev->dev.of_node, &of_mode,
OF_USE_NATIVE_MODE); OF_USE_NATIVE_MODE);
if (ret) if (ret)
return ret; goto failed_free_io;
ret = of_property_read_u32(pdev->dev.of_node, "bits-per-pixel", &bpp); ret = of_property_read_u32(pdev->dev.of_node, "bits-per-pixel", &bpp);
if (ret) if (ret)
return ret; goto failed_free_io;
/* try allocating the framebuffer */ /* try allocating the framebuffer */
fb_mem_len = of_mode.xres * of_mode.yres * 2 * (bpp / 8); fb_mem_len = of_mode.xres * of_mode.yres * 2 * (bpp / 8);
...@@ -364,7 +363,8 @@ static int vt8500lcd_probe(struct platform_device *pdev) ...@@ -364,7 +363,8 @@ static int vt8500lcd_probe(struct platform_device *pdev)
GFP_KERNEL); GFP_KERNEL);
if (!fb_mem_virt) { if (!fb_mem_virt) {
pr_err("%s: Failed to allocate framebuffer\n", __func__); pr_err("%s: Failed to allocate framebuffer\n", __func__);
return -ENOMEM; ret = -ENOMEM;
goto failed_free_io;
} }
fbi->fb.fix.smem_start = fb_mem_phys; fbi->fb.fix.smem_start = fb_mem_phys;
...@@ -447,9 +447,6 @@ static int vt8500lcd_probe(struct platform_device *pdev) ...@@ -447,9 +447,6 @@ static int vt8500lcd_probe(struct platform_device *pdev)
iounmap(fbi->regbase); iounmap(fbi->regbase);
failed_free_res: failed_free_res:
release_mem_region(res->start, resource_size(res)); release_mem_region(res->start, resource_size(res));
failed_fbi:
kfree(fbi);
failed:
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment