Linux Framebuffer Layer development
 help / color / mirror / Atom feed
* [PATCH] fbdev/hpfb: Fix an error handling path in hpfb_dio_probe()
@ 2024-07-28 18:29 Christophe JAILLET
  2024-07-29  8:13 ` Helge Deller
  0 siblings, 1 reply; 6+ messages in thread
From: Christophe JAILLET @ 2024-07-28 18:29 UTC (permalink / raw)
  To: Helge Deller
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET, linux-fbdev,
	dri-devel

If an error occurs after request_mem_region(), a corresponding
release_mem_region() should be called, as already done in the remove
function.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
*Not* even compile tested only.
I don't know on what architecture it relies on.

So it is provided as-is
---
 drivers/video/fbdev/hpfb.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/video/fbdev/hpfb.c b/drivers/video/fbdev/hpfb.c
index 66fac8e5393e..87b8dcdc1cf3 100644
--- a/drivers/video/fbdev/hpfb.c
+++ b/drivers/video/fbdev/hpfb.c
@@ -342,12 +342,17 @@ static int hpfb_dio_probe(struct dio_dev *d, const struct dio_device_id *ent)
 	}
 	printk(KERN_INFO "Topcat found at DIO select code %d "
 	       "(secondary id %02x)\n", d->scode, (d->id >> 8) & 0xff);
-	if (hpfb_init_one(paddr, vaddr)) {
-		if (d->scode >= DIOII_SCBASE)
-			iounmap((void *)vaddr);
-		return -ENOMEM;
-	}
+	if (hpfb_init_one(paddr, vaddr))
+		goto err_unmap;
+
 	return 0;
+
+err_unmap:
+	if (d->scode >= DIOII_SCBASE)
+		iounmap((void *)vaddr);
+	release_mem_region(d->resource.start, resource_size(&d->resource));
+
+	return -ENOMEM;
 }
 
 static void hpfb_remove_one(struct dio_dev *d)
-- 
2.45.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-07-29 21:35 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-28 18:29 [PATCH] fbdev/hpfb: Fix an error handling path in hpfb_dio_probe() Christophe JAILLET
2024-07-29  8:13 ` Helge Deller
2024-07-29 15:59   ` Dan Carpenter
2024-07-29 20:09     ` Helge Deller
2024-07-29 20:30       ` Christophe JAILLET
2024-07-29 21:35       ` Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox