From: Wang Jun <1742789905@qq.com>
To: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>,
Helge Deller <deller@gmx.de>
Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org,
linux-kernel@vger.kernel.org, gszhai@bjtu.edu.cn,
25125332@bjtu.edu.cn, 25125283@bjtu.edu.cn, 23120469@bjtu.edu.cn,
Wang Jun <1742789905@qq.com>
Subject: [PATCH] video/fbdev/via: check ioremap return value in viafb_lcd_get_mobile_state
Date: Tue, 10 Mar 2026 09:14:20 +0800 [thread overview]
Message-ID: <tencent_5706A404B952870FEAC83A04EEFC8348A305@qq.com> (raw)
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
next reply other threads:[~2026-03-10 8:14 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-10 1:14 Wang Jun [this message]
2026-03-10 16:36 ` [PATCH] video/fbdev/via: check ioremap return value in viafb_lcd_get_mobile_state Helge Deller
2026-03-11 3:49 ` Claude review: " Claude Code Review Bot
2026-03-11 3:49 ` Claude Code Review Bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tencent_5706A404B952870FEAC83A04EEFC8348A305@qq.com \
--to=1742789905@qq.com \
--cc=23120469@bjtu.edu.cn \
--cc=25125283@bjtu.edu.cn \
--cc=25125332@bjtu.edu.cn \
--cc=FlorianSchandinat@gmx.de \
--cc=deller@gmx.de \
--cc=dri-devel@lists.freedesktop.org \
--cc=gszhai@bjtu.edu.cn \
--cc=linux-fbdev@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox