Thread (1354 messages) 1354 messages, 168 authors, 2017-04-12

[PATCH 4/9] video: Add check for return value of ioremap() in cirrusfb_pci_register()

From: SF Markus Elfring <hidden>
Date: 2015-01-19 18:35:16
Also in: linux-fbdev, lkml
Subsystem: framebuffer layer, the rest · Maintainers: Helge Deller, Linus Torvalds

From: Markus Elfring <redacted>
Date: Mon, 19 Jan 2015 13:18:50 +0100

The return value from a call of the ioremap() function was not checked
by the implementation of the cirrusfb_pci_register() function.
Let us complete the corresponding error detection and exception handling
at this source code place.

Signed-off-by: Markus Elfring <redacted>
---
 drivers/video/fbdev/cirrusfb.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/video/fbdev/cirrusfb.c b/drivers/video/fbdev/cirrusfb.c
index d8b3359..aa4050c 100644
--- a/drivers/video/fbdev/cirrusfb.c
+++ b/drivers/video/fbdev/cirrusfb.c
@@ -2111,6 +2111,10 @@ static int cirrusfb_pci_register(struct pci_dev *pdev,
 	/* FIXME: this forces VGA.  alternatives? */
 	cinfo->regbase = NULL;
 	cinfo->laguna_mmio = ioremap(info->fix.mmio_start, 0x1000);
+	if (!cinfo->laguna_mmio) {
+		ret = -EIO;
+		goto err_release_fb;
+	}
 
 	dev_dbg(info->device, "Board address: 0x%lx, register address: 0x%lx\n",
 		board_addr, info->fix.mmio_start);
@@ -2122,7 +2126,7 @@ static int cirrusfb_pci_register(struct pci_dev *pdev,
 	if (ret < 0) {
 		dev_err(info->device, "cannot reserve region 0x%lx, abort\n",
 			board_addr);
-		goto err_release_fb;
+		goto io_unmap_laguna;
 	}
 #if 0 /* if the system didn't claim this region, we would... */
 	if (!request_mem_region(0xA0000, 65535, "cirrusfb")) {
@@ -2163,8 +2167,9 @@ err_release_legacy:
 err_release_regions:
 #endif
 	pci_release_regions(pdev);
-err_release_fb:
+io_unmap_laguna:
 	iounmap(cinfo->laguna_mmio);
+err_release_fb:
 	framebuffer_release(info);
 err_out:
 	return ret;
-- 
2.2.2
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help