[PATCH] fbdev: via: hw: Fix potential divide by zero
Alex Guo
alexguo1023 at gmail.com
Sat Jun 14 01:03:18 UTC 2025
Variable var->pixclock can be set by user. In case it equals to
zero, divide by zero would occur in viafb_fill_crtc_timing.
Similar crashes have happened in other fbdev drivers. We fix this
by checking whether 'pixclock' is zero.
Similar commit: commit 16844e58704 ("video: fbdev: tridentfb:
Error out if 'pixclock' equals zero")
Signed-off-by: Alex Guo <alexguo1023 at gmail.com>
---
drivers/video/fbdev/via/hw.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/video/fbdev/via/hw.c b/drivers/video/fbdev/via/hw.c
index 66afd7be00cc..31e0cac91889 100644
--- a/drivers/video/fbdev/via/hw.c
+++ b/drivers/video/fbdev/via/hw.c
@@ -1488,8 +1488,9 @@ void viafb_fill_crtc_timing(const struct fb_var_screeninfo *var,
if (viaparinfo->chip_info->gfx_chip_name != UNICHROME_CLE266
&& viaparinfo->chip_info->gfx_chip_name != UNICHROME_K400)
viafb_load_FIFO_reg(iga, var->xres, var->yres);
-
- viafb_set_vclock(PICOS2KHZ(var->pixclock) * 1000, iga);
+
+ if (var->pixclock)
+ viafb_set_vclock(PICOS2KHZ(var->pixclock) * 1000, iga);
}
void viafb_init_chip_info(int chip_type)
--
2.34.1
More information about the dri-devel
mailing list