public inbox for drm-ai-reviews@public-inbox.freedesktop.org
 help / color / mirror / Atom feed
* [PATCH] video/fbdev/via: check ioremap return value in viafb_lcd_get_mobile_state
@ 2026-03-10  1:14 Wang Jun
  2026-03-10 16:36 ` Helge Deller
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Wang Jun @ 2026-03-10  1:14 UTC (permalink / raw)
  To: Florian Tobias Schandinat, Helge Deller
  Cc: linux-fbdev, dri-devel, linux-kernel, gszhai, 25125332, 25125283,
	23120469, Wang Jun

The function viafb_lcd_get_mobile_state() calls ioremap() without
checking the return value. If ioremap() fails (returns NULL), the
subsequent readw() will cause a NULL pointer dereference.

This patch adds a proper NULL check after ioremap() and returns
-ENOMEM in case of failure.

Signed-off-by: Wang Jun <1742789905@qq.com>
---
 drivers/video/fbdev/via/lcd.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/video/fbdev/via/lcd.c b/drivers/video/fbdev/via/lcd.c
index 8673fced8749..91359d2b64fb 100644
--- a/drivers/video/fbdev/via/lcd.c
+++ b/drivers/video/fbdev/via/lcd.c
@@ -954,6 +954,10 @@ bool viafb_lcd_get_mobile_state(bool *mobile)
 	u16 start_pattern;
 
 	biosptr = ioremap(romaddr, 0x10000);
+	if (!biosptr) {
+		DEBUG_MSG(KERN_ERR " Failed to remap BIOS memory\n");
+		return false;
+	}
 	start_pattern = readw(biosptr);
 
 	/* Compare pattern */
-- 
2.43.0


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

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

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-10  1:14 [PATCH] video/fbdev/via: check ioremap return value in viafb_lcd_get_mobile_state Wang Jun
2026-03-10 16:36 ` Helge Deller
2026-03-11  3:49 ` Claude review: " Claude Code Review Bot
2026-03-11  3:49 ` 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