* [PATCH] fbdev: i810 Fix potential divide by zero
@ 2025-06-14 5:26 Alex Guo
0 siblings, 0 replies; only message in thread
From: Alex Guo @ 2025-06-14 5:26 UTC (permalink / raw)
To: deller; +Cc: alexguo1023, linux-fbdev, dri-devel, linux-kernel
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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2025-06-14 5:26 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-14 5:26 [PATCH] fbdev: i810 Fix potential divide by zero Alex Guo
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).