lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 19 Jan 2015 19:46:57 +0100
From:	SF Markus Elfring <elfring@...rs.sourceforge.net>
To:	Jean-Christophe Plagniol-Villard <plagnioj@...osoft.com>,
	Tomi Valkeinen <tomi.valkeinen@...com>,
	linux-fbdev@...r.kernel.org
CC:	LKML <linux-kernel@...r.kernel.org>,
	kernel-janitors@...r.kernel.org,
	Julia Lawall <julia.lawall@...6.fr>
Subject: [PATCH 8/9] video: Less function calls in valkyriefb_init() after
 error detection

From: Markus Elfring <elfring@...rs.sourceforge.net>
Date: Mon, 19 Jan 2015 17:01:25 +0100

The iounmap() function could be called in three cases by the valkyriefb_init()
function during error handling even if the passed data structure element
contained still a null pointer.

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

Signed-off-by: Markus Elfring <elfring@...rs.sourceforge.net>
---
 drivers/video/fbdev/valkyriefb.c | 32 +++++++++++++++++++++-----------
 1 file changed, 21 insertions(+), 11 deletions(-)

diff --git a/drivers/video/fbdev/valkyriefb.c b/drivers/video/fbdev/valkyriefb.c
index 2a9213b..a81a0f1 100644
--- a/drivers/video/fbdev/valkyriefb.c
+++ b/drivers/video/fbdev/valkyriefb.c
@@ -369,40 +369,50 @@ int __init valkyriefb_init(void)
 	}
 	p->total_vram = 0x100000;
 	p->frame_buffer_phys = frame_buffer_phys;
+	err = -ENOMEM;
 	p->frame_buffer = __ioremap(frame_buffer_phys, p->total_vram, flags);
+	if (p->frame_buffer == NULL) {
+		pr_err("%s: %s failed\n", __func__, "Frame buffer mapping");
+		goto free_memory;
+	}
 	p->cmap_regs_phys = cmap_regs_phys;
 	p->cmap_regs = ioremap(p->cmap_regs_phys, 0x1000);
+	if (p->cmap_regs == NULL) {
+		pr_err("%s: %s failed\n", __func__, "cmap");
+		goto io_unmap_framebuffer;
+	}
 	p->valkyrie_regs_phys = cmap_regs_phys+0x6000;
 	p->valkyrie_regs = ioremap(p->valkyrie_regs_phys, 0x1000);
-	err = -ENOMEM;
-	if (p->frame_buffer == NULL || p->cmap_regs == NULL
-	    || p->valkyrie_regs == NULL) {
-		printk(KERN_ERR "valkyriefb: couldn't map resources\n");
-		goto out_free;
+	if (p->valkyrie_regs == NULL) {
+		pr_err("%s: %s failed\n", __func__, "ioremap");
+		goto io_unmap_cmap;
 	}
 
 	valkyrie_choose_mode(p);
 	mac_vmode_to_var(default_vmode, default_cmode, &p->info.var);
 	err = valkyrie_init_info(&p->info, p);
 	if (err < 0)
-		goto out_free;
+		goto io_unmap_valkyrie;
 	valkyrie_init_fix(&p->info.fix, p);
 	if (valkyriefb_set_par(&p->info))
 		/* "can't happen" */
 		printk(KERN_ERR "valkyriefb: can't set default video mode\n");
 
 	if ((err = register_framebuffer(&p->info)) != 0)
-		goto out_cmap_free;
+		goto dealloc_cmap;
 
 	fb_info(&p->info, "valkyrie frame buffer device\n");
 	return 0;
 
- out_cmap_free:
+dealloc_cmap:
 	fb_dealloc_cmap(&p->info.cmap);
- out_free:
-	iounmap(p->frame_buffer);
-	iounmap(p->cmap_regs);
+io_unmap_valkyrie:
 	iounmap(p->valkyrie_regs);
+io_unmap_cmap:
+	iounmap(p->cmap_regs);
+io_unmap_framebuffer:
+	iounmap(p->frame_buffer);
+free_memory:
 	kfree(p);
 	return err;
 }
-- 
2.2.2

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ