linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: SF Markus Elfring <elfring@users.sourceforge.net>
To: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>,
	Tomi Valkeinen <tomi.valkeinen@ti.com>,
	linux-fbdev@vger.kernel.org
Cc: LKML <linux-kernel@vger.kernel.org>,
	kernel-janitors@vger.kernel.org,
	Julia Lawall <julia.lawall@lip6.fr>
Subject: [PATCH 9/9] video: Less function calls in w100fb_probe() after error detection
Date: Mon, 19 Jan 2015 18:49:39 +0000	[thread overview]
Message-ID: <54BD51C3.8000507@users.sourceforge.net> (raw)
In-Reply-To: <54BD44F0.3040705@users.sourceforge.net>

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 19 Jan 2015 17:56:11 +0100

The iounmap() function could be called in three cases by the w100fb_probe()
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.

* Let us also delete two unnecessary null pointer checks for the
  variable "info".

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/video/fbdev/w100fb.c | 31 +++++++++++++++++--------------
 1 file changed, 17 insertions(+), 14 deletions(-)

diff --git a/drivers/video/fbdev/w100fb.c b/drivers/video/fbdev/w100fb.c
index aeb53eb..67ddc57 100644
--- a/drivers/video/fbdev/w100fb.c
+++ b/drivers/video/fbdev/w100fb.c
@@ -645,12 +645,12 @@ int w100fb_probe(struct platform_device *pdev)
 	/* Remap the chip base address */
 	remapped_base = ioremap_nocache(mem->start+W100_CFG_BASE, W100_CFG_LEN);
 	if (remapped_base = NULL)
-		goto out;
+		goto exit;
 
 	/* Map the register space */
 	remapped_regs = ioremap_nocache(mem->start+W100_REG_BASE, W100_REG_LEN);
 	if (remapped_regs = NULL)
-		goto out;
+		goto io_unmap_base;
 
 	/* Identify the chip */
 	printk("Found ");
@@ -662,19 +662,19 @@ int w100fb_probe(struct platform_device *pdev)
 		default:
 			printk("Unknown imageon chip ID\n");
 			err = -ENODEV;
-			goto out;
+			goto io_unmap_regs;
 	}
 	printk(" at 0x%08lx.\n", (unsigned long) mem->start+W100_CFG_BASE);
 
 	/* Remap the framebuffer */
 	remapped_fbuf = ioremap_nocache(mem->start+MEM_WINDOW_BASE, MEM_WINDOW_SIZE);
 	if (remapped_fbuf = NULL)
-		goto out;
+		goto io_unmap_regs;
 
 	info=framebuffer_alloc(sizeof(struct w100fb_par), &pdev->dev);
 	if (!info) {
 		err = -ENOMEM;
-		goto out;
+		goto io_unmap_framebuffer;
 	}
 
 	par = info->par;
@@ -690,13 +690,13 @@ int w100fb_probe(struct platform_device *pdev)
 	if (!par->pll_table) {
 		printk(KERN_ERR "No matching Xtal definition found\n");
 		err = -EINVAL;
-		goto out;
+		goto release_framebuffer;
 	}
 
 	info->pseudo_palette = kmalloc(sizeof (u32) * MAX_PALETTES, GFP_KERNEL);
 	if (!info->pseudo_palette) {
 		err = -ENOMEM;
-		goto out;
+		goto release_framebuffer;
 	}
 
 	info->fbops = &w100fb_ops;
@@ -716,7 +716,7 @@ int w100fb_probe(struct platform_device *pdev)
 
 	if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
 		err = -ENOMEM;
-		goto out;
+		goto free_palette;
 	}
 
 	par->mode = &inf->modelist[0];
@@ -766,15 +766,18 @@ int w100fb_probe(struct platform_device *pdev)
 	fb_info(info, "%s frame buffer device\n", info->fix.id);
 	return 0;
 out:
-	if (info) {
-		fb_dealloc_cmap(&info->cmap);
-		kfree(info->pseudo_palette);
-	}
+	fb_dealloc_cmap(&info->cmap);
+free_palette:
+	kfree(info->pseudo_palette);
+release_framebuffer:
+	framebuffer_release(info);
+io_unmap_framebuffer:
 	iounmap(remapped_fbuf);
+io_unmap_regs:
 	iounmap(remapped_regs);
+io_unmap_base:
 	iounmap(remapped_base);
-	if (info)
-		framebuffer_release(info);
+exit:
 	return err;
 }
 
-- 
2.2.2


  parent reply	other threads:[~2015-01-19 18:49 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <5307CAA2.8060406@users.sourceforge.net>
     [not found] ` <alpine.DEB.2.02.1402212321410.2043@localhost6.localdomain6>
     [not found]   ` <530A086E.8010901@users.sourceforge.net>
     [not found]     ` <alpine.DEB.2.02.1402231635510.1985@localhost6.localdomain6>
     [not found]       ` <530A72AA.3000601@users.sourceforge.net>
     [not found]         ` <alpine.DEB.2.02.1402240658210.2090@localhost6.localdomain6>
     [not found]           ` <530B5FB6.6010207@users.sourceforge.net>
     [not found]             ` <alpine.DEB.2.10.1402241710370.2074@hadrien>
     [not found]               ` <530C5E18.1020800@users.sourceforge.net>
     [not found]                 ` <alpine.DEB.2.10.1402251014170.2080@hadrien>
     [not found]                   ` <530CD2C4.4050903@users.sourceforge.net>
     [not found]                     ` <alpine.DEB.2.10.1402251840450.7035@hadrien>
     [not found]                       ` <530CF8FF.8080600@users.sourceforge.net>
     [not found]                         ` <alpine.DEB.2.02.1402252117150.2047@localhost6.localdomain6>
     [not found]                           ` <530DD06F.4090703@users.sourceforge.net>
     [not found]                             ` <alpine.DEB.2.02.1402262129250.2221@localhost6.localdomain6>
     [not found]                               ` <5317A59D.4@users.sourceforge.net>
2014-11-22 16:00                                 ` [PATCH 1/1] video: fbdev-LCDC: Deletion of an unnecessary check before the function call "vfree" SF Markus Elfring
2014-12-04 14:19                                   ` Tomi Valkeinen
2014-11-23 10:11                                 ` [PATCH 1/1] video: uvesafb: Deletion of an unnecessary check before the function call "uvesafb_free" SF Markus Elfring
2014-11-23 10:44                                 ` [PATCH 1/1] video: udlfb: Deletion of unnecessary checks before the function call "vfree" SF Markus Elfring
2014-11-23 11:33                                 ` [PATCH 1/1] video: smscufx: " SF Markus Elfring
2014-11-23 12:00                                 ` [PATCH 1/1] video: fbdev-SIS: Deletion of unnecessary checks before the function call "pci_dev_put" SF Markus Elfring
2014-11-23 13:14                                 ` [PATCH 1/1] video: fbdev-OMAP2: Deletion of unnecessary checks before the function call "i2c_put_ada SF Markus Elfring
2014-11-23 14:20                                 ` [PATCH 1/1] video: mx3fb: Deletion of an unnecessary check before the function call "backlight_devic SF Markus Elfring
2014-11-23 15:00                                 ` [PATCH 1/1] video: fbdev-MMP: Deletion of an unnecessary check before the function call "mmp_unregis SF Markus Elfring
2014-11-23 15:33                                 ` [PATCH 1/1] video: fbdev-VIA: Deletion of an unnecessary check before the function call "framebuffer SF Markus Elfring
2014-11-23 16:10                                 ` [PATCH 1/1] video: uvesafb: Deletion of an unnecessary check before the function call "platform_devi SF Markus Elfring
2014-11-23 16:40                                 ` [PATCH 1/1] backlight: lp8788: Deletion of an unnecessary check before the function call "backlight_ SF Markus Elfring
2014-11-24 10:09                                   ` [PATCH 1/1] backlight: lp8788: Deletion of an unnecessary check before the function call "backli Lee Jones
2014-11-24 10:10                                   ` Lee Jones
2014-11-24 18:05                                     ` [PATCH v2] backlight: lp8788: Deletion of a check before backlight_device_unregister() SF Markus Elfring
2015-06-28 12:07                                       ` SF Markus Elfring
2015-07-01  8:06                                         ` Lee Jones
2015-07-01 10:30                                           ` [PATCH v3] video-lp8788: Delete " SF Markus Elfring
2015-07-02  4:44                                             ` Jingoo Han
2015-07-07  7:13                                             ` Lee Jones
2015-01-19 17:54                                 ` [PATCH 0/9] video: fbdev: Deletion of some unnecessary checks SF Markus Elfring
2015-01-19 18:00                                   ` [PATCH 1/9] video: Deletion of checks before the function call "iounmap" SF Markus Elfring
2015-01-19 18:25                                   ` video: One function call less in tdfxfb_probe() after error detection SF Markus Elfring
2015-01-19 18:30                                   ` [PATCH 3/9] video: One function call less in vesafb_probe() after, " SF Markus Elfring
2015-01-19 18:34                                   ` [PATCH 4/9] video: Add check for return value of ioremap() in cirrusfb_pci_register() SF Markus Elfring
2015-01-19 18:38                                   ` [PATCH 5/9] video: Less function calls in trident_pci_probe() after error detection SF Markus Elfring
2015-01-19 18:41                                   ` [PATCH 6/9] video: One function call less in pvr2fb_common_init() " SF Markus Elfring
2015-01-19 18:43                                   ` [PATCH 7/9] video: One function call less in tgafb_register() after, " SF Markus Elfring
2015-01-19 18:46                                   ` [PATCH 8/9] video: Less function calls in valkyriefb_init() after " SF Markus Elfring
2015-01-19 18:49                                   ` SF Markus Elfring [this message]
2015-02-05 13:14                                 ` [PATCH] au1100fb: Delete unnecessary checks before two function calls SF Markus Elfring
2015-02-05 13:41                                   ` Dan Carpenter
2015-02-05 14:20                                     ` SF Markus Elfring
2015-02-05 17:18                                       ` Dan Carpenter
2015-02-05 20:15                                         ` SF Markus Elfring
2015-02-21 13:26                                 ` [PATCH] video: fbdev-SIS: Deletion of unnecessary checks before three " SF Markus Elfring
2015-06-28 12:36                                 ` [PATCH] video: fbdev: omap2: displays-new: Delete a check before backlight_device_unregister() SF Markus Elfring
2016-07-23 17:37                                 ` [PATCH] omapfb: panel-dsi-cm: Delete an unnecessary " SF Markus Elfring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=54BD51C3.8000507@users.sourceforge.net \
    --to=elfring@users.sourceforge.net \
    --cc=julia.lawall@lip6.fr \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=plagnioj@jcrosoft.com \
    --cc=tomi.valkeinen@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).