summaryrefslogtreecommitdiff
path: root/drivers/video
diff options
context:
space:
mode:
authorZheyu Ma <zheyuma97@gmail.com>2022-04-04 16:47:19 +0800
committerHelge Deller <deller@gmx.de>2022-04-11 08:23:49 +0200
commit213e2df4733275165038d77289812d4473b0b010 (patch)
tree1ed5a45d00f73105df698d6a7a5bba9abef9ee18 /drivers/video
parent85ec038b53faec11baefb2c42b6c0ce8bec94d3e (diff)
video: fbdev: kyro: Error out if 'lineclock' equals zero
The userspace program could pass any values to the driver through ioctl() interface. If the driver doesn't check the value of 'lineclock', it may cause divide error. Fix this by checking whether 'lineclock' is zero. The following log reveals it: divide error: 0000 [#1] PREEMPT SMP KASAN PTI RIP: 0010:kyrofb_set_par+0x30d/0xd80 Call Trace: <TASK> fb_set_var+0x604/0xeb0 do_fb_ioctl+0x234/0x670 fb_ioctl+0xdd/0x130 do_syscall_64+0x3b/0x90 Signed-off-by: Zheyu Ma <zheyuma97@gmail.com> Signed-off-by: Helge Deller <deller@gmx.de>
Diffstat (limited to 'drivers/video')
-rw-r--r--drivers/video/fbdev/kyro/fbdev.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/video/fbdev/kyro/fbdev.c b/drivers/video/fbdev/kyro/fbdev.c
index 25801e8e3f74..d57772f96ad2 100644
--- a/drivers/video/fbdev/kyro/fbdev.c
+++ b/drivers/video/fbdev/kyro/fbdev.c
@@ -494,6 +494,8 @@ static int kyrofb_set_par(struct fb_info *info)
info->var.hsync_len +
info->var.left_margin)) / 1000;
+ if (!lineclock)
+ return -EINVAL;
/* time for a frame in ns (precision in 32bpp) */
frameclock = lineclock * (info->var.yres +