[PATCH 7/9] video: One function call less in tgafb_register() after, error detection

From: SF Markus Elfring
Date: Mon Jan 19 2015 - 13:43:51 EST


From: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 19 Jan 2015 15:30:45 +0100

The iounmap() function could be called in one case by the tgafb_register()
function during error handling even if the passed variable "mem_base"
contained still a null pointer.

This implementation detail could be improved by adjustments for jump labels
(according also to current Linux coding style).

Signed-off-by: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
---
drivers/video/fbdev/tgafb.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/video/fbdev/tgafb.c b/drivers/video/fbdev/tgafb.c
index b6fb7e8..a3cd0ef 100644
--- a/drivers/video/fbdev/tgafb.c
+++ b/drivers/video/fbdev/tgafb.c
@@ -1436,14 +1436,14 @@ static int tgafb_register(struct device *dev)
}
if (!request_mem_region (bar0_start, bar0_len, "tgafb")) {
printk(KERN_ERR "tgafb: cannot reserve FB region\n");
- goto err0;
+ goto release_framebuffer;
}

/* Map the framebuffer. */
mem_base = ioremap_nocache(bar0_start, bar0_len);
if (!mem_base) {
printk(KERN_ERR "tgafb: Cannot map MMIO\n");
- goto err1;
+ goto release_memory_region;
}

/* Grab info about the card. */
@@ -1484,13 +1484,13 @@ static int tgafb_register(struct device *dev)
if (ret == 0 || ret == 4) {
printk(KERN_ERR "tgafb: Could not find valid video mode\n");
ret = -EINVAL;
- goto err1;
+ goto io_unmap;
}

if (fb_alloc_cmap(&info->cmap, 256, 0)) {
printk(KERN_ERR "tgafb: Could not allocate color map\n");
ret = -ENOMEM;
- goto err1;
+ goto io_unmap;
}

tgafb_set_par(info);
@@ -1498,7 +1498,7 @@ static int tgafb_register(struct device *dev)
if (register_framebuffer(info) < 0) {
printk(KERN_ERR "tgafb: Could not register framebuffer\n");
ret = -EINVAL;
- goto err2;
+ goto dealloc_cmap;
}

if (tga_bus_pci) {
@@ -1517,12 +1517,13 @@ static int tgafb_register(struct device *dev)

return 0;

- err2:
+dealloc_cmap:
fb_dealloc_cmap(&info->cmap);
- err1:
+io_unmap:
iounmap(mem_base);
+release_memory_region:
release_mem_region(bar0_start, bar0_len);
- err0:
+release_framebuffer:
framebuffer_release(info);
return ret;
}
--
2.2.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/