Skip to contentSkip to conversation

fbdev: sstfb: Fix potential divide by zero

PATCH New Alex Guo 1 participant 1 message Jun 14, 2025 Framebuffer layer

lore
Share & tools
lore

Alex Guo

author
#0 lore raw

PATCH 1/1 fbdev: sstfb: Fix potential divide by zero

Variable var->pixclock can be set by user. In case it equals to
zero, divide by zero would occur in sstfb_check_var. Similar
crashes have happened in other fbdev drivers. We fix this by checking whether 'pixclock' is zero.

---
 drivers/video/fbdev/sstfb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/video/fbdev/sstfb.c +1 -1
index 2ea947f57efb..fd387ca8401b 100644
@@ -359,7 +359,7 @@ static int sstfb_check_var(struct fb_var_screeninfo *var,
 	int tiles_in_X, real_length;
 	unsigned int freq;
 
-	if (sst_calc_pll(PICOS2KHZ(var->pixclock), &freq, &par->pll)) {
+	if (var->pixclock && sst_calc_pll(PICOS2KHZ(var->pixclock), &freq, &par->pll)) {
 		printk(KERN_ERR "sstfb: Pixclock at %ld KHZ out of range\n",
 				PICOS2KHZ(var->pixclock));
 		return -EINVAL;
Signature · 1 line
2.34.1