Skip to content

Commit 3f6dae0

Browse files
Sergey Shtylyovhdeller
authored andcommitted
fbdev: core: fbcvt: avoid division by 0 in fb_cvt_hperiod()
In fb_find_mode_cvt(), iff mode->refresh somehow happens to be 0x80000000, cvt.f_refresh will become 0 when multiplying it by 2 due to overflow. It's then passed to fb_cvt_hperiod(), where it's used as a divider -- division by 0 will result in kernel oops. Add a sanity check for cvt.f_refresh to avoid such overflow... Found by Linux Verification Center (linuxtesting.org) with the Svace static analysis tool. Fixes: 96fe6a2 ("[PATCH] fbdev: Add VESA Coordinated Video Timings (CVT) support") Signed-off-by: Sergey Shtylyov <[email protected]> Signed-off-by: Helge Deller <[email protected]>
1 parent cedc1b6 commit 3f6dae0

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/video/fbdev/core/fbcvt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ int fb_find_mode_cvt(struct fb_videomode *mode, int margins, int rb)
312312
cvt.f_refresh = cvt.refresh;
313313
cvt.interlace = 1;
314314

315-
if (!cvt.xres || !cvt.yres || !cvt.refresh) {
315+
if (!cvt.xres || !cvt.yres || !cvt.refresh || cvt.f_refresh > INT_MAX) {
316316
printk(KERN_INFO "fbcvt: Invalid input parameters\n");
317317
return 1;
318318
}

0 commit comments

Comments
 (0)