* [PATCH] fbdev: tdfxfb: Fix potential divide by zero
@ 2025-06-14 0:56 Alex Guo
0 siblings, 0 replies; only message in thread
From: Alex Guo @ 2025-06-14 0:56 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 tdfxfb_check_var. Similar
crashes have happened in other fbdev drivers. We fix this by
checking whether 'pixclock' is zero.
Signed-off-by: Alex Guo <alexguo1023@gmail.com>
---
drivers/video/fbdev/tdfxfb.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/video/fbdev/tdfxfb.c b/drivers/video/fbdev/tdfxfb.c
index 51ebe78359ec..2100857fa7b3 100644
--- a/drivers/video/fbdev/tdfxfb.c
+++ b/drivers/video/fbdev/tdfxfb.c
@@ -495,6 +495,9 @@ static int tdfxfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
return -EINVAL;
}
}
+
+ if (var->pixclock <= KHZ2PICOS(par->max_pixclock))
+ var->pixclock = KHZ2PICOS(par->max_pixclock) + 1;
if (PICOS2KHZ(var->pixclock) > par->max_pixclock) {
DPRINTK("pixclock too high (%ldKHz)\n",
--
2.34.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2025-06-14 0:56 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-14 0:56 [PATCH] fbdev: tdfxfb: 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