From: Alex Guo <alexguo1023@gmail.com>
To: deller@gmx.de
Cc: alexguo1023@gmail.com, linux-fbdev@vger.kernel.org,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: [PATCH] fbdev: i810 Fix potential divide by zero
Date: Sat, 14 Jun 2025 01:26:29 -0400 [thread overview]
Message-ID: <20250614052629.3549586-1-alexguo1023@gmail.com> (raw)
Variable var->pixclock can be set by user. In case it equals to
zero, divide by zero would occur in i810fb_fill_var_timings and
i810_get_watermark.
We cannot find the default valid value of pixclock for driver
i810, so we fix this by returning directly if 'pixclock' is
zero.
Similar commit: commit 16844e58704 ("video: fbdev: tridentfb:
Error out if 'pixclock' equals zero")
Signed-off-by: Alex Guo <alexguo1023@gmail.com>
---
drivers/video/fbdev/i810/i810_dvt.c | 2 ++
drivers/video/fbdev/i810/i810_gtf.c | 2 ++
2 files changed, 4 insertions(+)
diff --git a/drivers/video/fbdev/i810/i810_dvt.c b/drivers/video/fbdev/i810/i810_dvt.c
index 2082b5c92e8f..1db4a63a2631 100644
--- a/drivers/video/fbdev/i810/i810_dvt.c
+++ b/drivers/video/fbdev/i810/i810_dvt.c
@@ -251,6 +251,8 @@ void i810fb_fill_var_timings(struct fb_var_screeninfo *var)
xres = var->xres;
yres = var->yres;
+ if (!var->pixclock)
+ return;
pixclock = 1000000000 / var->pixclock;
mode = i810fb_find_best_mode(xres, yres, pixclock);
diff --git a/drivers/video/fbdev/i810/i810_gtf.c b/drivers/video/fbdev/i810/i810_gtf.c
index 9743d51e7f8c..ae001b256ace 100644
--- a/drivers/video/fbdev/i810/i810_gtf.c
+++ b/drivers/video/fbdev/i810/i810_gtf.c
@@ -259,6 +259,8 @@ u32 i810_get_watermark(const struct fb_var_screeninfo *var,
}
}
+ if (!var->pixclock)
+ return -EINVAL;
pixclock = 1000000/var->pixclock;
min = ~0;
for (i = 0; i < size; i++) {
--
2.34.1
reply other threads:[~2025-06-14 5:26 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20250614052629.3549586-1-alexguo1023@gmail.com \
--to=alexguo1023@gmail.com \
--cc=deller@gmx.de \
--cc=dri-devel@lists.freedesktop.org \
--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;
as well as URLs for NNTP newsgroup(s).