Skip to content

Commit 15cf0b8

Browse files
ZheyuMahdeller
authored andcommitted
video: fbdev: i740fb: Error out if 'pixclock' equals zero
The userspace program could pass any values to the driver through ioctl() interface. If the driver doesn't check the value of 'pixclock', it may cause divide error. Fix this by checking whether 'pixclock' is zero in the function i740fb_check_var(). The following log reveals it: divide error: 0000 [#1] PREEMPT SMP KASAN PTI RIP: 0010:i740fb_decode_var drivers/video/fbdev/i740fb.c:444 [inline] RIP: 0010:i740fb_set_par+0x272f/0x3bb0 drivers/video/fbdev/i740fb.c:739 Call Trace: fb_set_var+0x604/0xeb0 drivers/video/fbdev/core/fbmem.c:1036 do_fb_ioctl+0x234/0x670 drivers/video/fbdev/core/fbmem.c:1112 fb_ioctl+0xdd/0x130 drivers/video/fbdev/core/fbmem.c:1191 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:874 [inline] Signed-off-by: Zheyu Ma <zheyuma97@gmail.com> Signed-off-by: Helge Deller <deller@gmx.de>
1 parent 12acdbd commit 15cf0b8

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

drivers/video/fbdev/i740fb.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,9 @@ static int i740fb_decode_var(const struct fb_var_screeninfo *var,
657657

658658
static int i740fb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
659659
{
660+
if (!var->pixclock)
661+
return -EINVAL;
662+
660663
switch (var->bits_per_pixel) {
661664
case 8:
662665
var->red.offset = var->green.offset = var->blue.offset = 0;

0 commit comments

Comments
 (0)