public inbox for drm-ai-reviews@public-inbox.freedesktop.org
 help / color / mirror / Atom feed
* [PATCH] fbdev/hga: Request memory region before ioremap
@ 2026-03-10  6:41 Hardik Phalet
  2026-03-10 10:03 ` Thomas Zimmermann
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Hardik Phalet @ 2026-03-10  6:41 UTC (permalink / raw)
  To: Ferenc Bakonyi, Helge Deller
  Cc: Shuah Khan, Brigham Campbell, Thomas Zimmermann, linux-nvidia,
	linux-fbdev, dri-devel, linux-kernel, Hardik Phalet

The driver calls ioremap() on the HGA video memory at 0xb0000 without
first reserving the physical address range via request_mem_region().
This leaves the kernel resource tree incomplete and can cause silent
conflicts with other drivers claiming the same range.

Add a request_mem_region() call before ioremap() in hga_card_detect()
and release the region in all error paths and in hgafb_remove().

Signed-off-by: Hardik Phalet <hardik.phalet@pm.me>
---
 drivers/video/fbdev/hgafb.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/video/fbdev/hgafb.c b/drivers/video/fbdev/hgafb.c
index 14418aa3791a..ceca6cc2c928 100644
--- a/drivers/video/fbdev/hgafb.c
+++ b/drivers/video/fbdev/hgafb.c
@@ -284,9 +284,16 @@ static int hga_card_detect(void)
 
 	hga_vram_len  = 0x08000;
 
+	if (!request_mem_region(0xb0000, hga_vram_len, "hgafb")) {
+		pr_err("hgafb: cannot reserve video memory at 0xb0000\n");
+		return -EBUSY;
+	}
+
 	hga_vram = ioremap(0xb0000, hga_vram_len);
-	if (!hga_vram)
+	if (!hga_vram) {
+		release_mem_region(0xb0000, hga_vram_len);
 		return -ENOMEM;
+	}
 
 	if (request_region(0x3b0, 12, "hgafb"))
 		release_io_ports = 1;
@@ -348,6 +355,7 @@ static int hga_card_detect(void)
 	}
 	return 0;
 error:
+	release_mem_region(0xb0000, hga_vram_len);
 	if (release_io_ports)
 		release_region(0x3b0, 12);
 	if (release_io_port)
@@ -619,6 +627,7 @@ static void hgafb_remove(struct platform_device *pdev)
 	}
 
 	iounmap(hga_vram);
+	release_mem_region(0xb0000, hga_vram_len);
 
 	if (release_io_ports)
 		release_region(0x3b0, 12);
-- 
2.53.0



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

end of thread, other threads:[~2026-03-11  3:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-10  6:41 [PATCH] fbdev/hga: Request memory region before ioremap Hardik Phalet
2026-03-10 10:03 ` Thomas Zimmermann
2026-03-11  3:36 ` Claude review: " Claude Code Review Bot
2026-03-11  3:36 ` Claude Code Review Bot

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