diff mbox

[5/9] video: Less function calls in trident_pci_probe() after error detection

Message ID 54BD4F10.9040401@users.sourceforge.net (mailing list archive)
State New, archived
Headers show

Commit Message

SF Markus Elfring Jan. 19, 2015, 6:38 p.m. UTC
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 19 Jan 2015 14:18:47 +0100

The functions "iounmap" and "kfree" could be called in a few cases by the
trident_pci_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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/video/fbdev/tridentfb.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
diff mbox

Patch

diff --git a/drivers/video/fbdev/tridentfb.c b/drivers/video/fbdev/tridentfb.c
index 71567401..86d4733 100644
--- a/drivers/video/fbdev/tridentfb.c
+++ b/drivers/video/fbdev/tridentfb.c
@@ -1436,7 +1436,7 @@  static int trident_pci_probe(struct pci_dev *dev,
 	if (!default_par->io_virt) {
 		debug("ioremap failed\n");
 		err = -1;
-		goto out_unmap1;
+		goto release_memory_region_mmio;
 	}
 
 	enable_mmio(default_par);
@@ -1459,7 +1459,7 @@  static int trident_pci_probe(struct pci_dev *dev,
 	if (!info->screen_base) {
 		debug("ioremap failed\n");
 		err = -1;
-		goto out_unmap2;
+		goto release_memory_region_smem;
 	}
 
 	default_par->flatpanel = is_flatpanel(default_par);
@@ -1485,7 +1485,7 @@  static int trident_pci_probe(struct pci_dev *dev,
 	info->pixmap.addr = kmalloc(4096, GFP_KERNEL);
 	if (!info->pixmap.addr) {
 		err = -ENOMEM;
-		goto out_unmap2;
+		goto io_unmap_screenbase;
 	}
 
 	info->pixmap.size = 4096;
@@ -1531,11 +1531,14 @@  static int trident_pci_probe(struct pci_dev *dev,
 
 out_unmap2:
 	kfree(info->pixmap.addr);
+io_unmap_screenbase:
 	iounmap(info->screen_base);
+release_memory_region_smem:
 	release_mem_region(tridentfb_fix.smem_start, tridentfb_fix.smem_len);
 	disable_mmio(info->par);
 out_unmap1:
 	iounmap(default_par->io_virt);
+release_memory_region_mmio:
 	release_mem_region(tridentfb_fix.mmio_start, tridentfb_fix.mmio_len);
 	framebuffer_release(info);
 	return err;