[PATCH 3/7] video: fbdev: kyro: Error out if 'lineclock' equals zero

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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:

[   33.404918] divide error: 0000 [#1] PREEMPT SMP KASAN PTI
[   33.404932] RIP: 0010:kyrofb_set_par+0x30d/0xd80
[   33.404976] Call Trace:
[   33.404978]  <TASK>
[   33.404987]  fb_set_var+0x604/0xeb0
[   33.405038]  do_fb_ioctl+0x234/0x670
[   33.405083]  fb_ioctl+0xdd/0x130
[   33.405091]  do_syscall_64+0x3b/0x90

Signed-off-by: Zheyu Ma <zheyuma97@xxxxxxxxx>
---
 drivers/video/fbdev/kyro/fbdev.c | 2 ++
 1 file changed, 2 insertions(+)

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 +
-- 
2.25.1




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux