Skip to content

Commit f90bd24

Browse files
harperchenhdeller
authored andcommitted
fbdev: tgafb: Fix potential divide by zero
fb_set_var would by called when user invokes ioctl with cmd FBIOPUT_VSCREENINFO. User-provided data would finally reach tgafb_check_var. In case var->pixclock is assigned to zero, divide by zero would occur when checking whether reciprocal of var->pixclock is too high. Similar crashes have happened in other fbdev drivers. There is no check and modification on var->pixclock along the call chain to tgafb_check_var. We believe it could also be triggered in driver tgafb from user site. Signed-off-by: Wei Chen <[email protected]> Signed-off-by: Helge Deller <[email protected]>
1 parent 33bf61c commit f90bd24

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/video/fbdev/tgafb.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,9 @@ tgafb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
173173
{
174174
struct tga_par *par = (struct tga_par *)info->par;
175175

176+
if (!var->pixclock)
177+
return -EINVAL;
178+
176179
if (par->tga_type == TGA_TYPE_8PLANE) {
177180
if (var->bits_per_pixel != 8)
178181
return -EINVAL;

0 commit comments

Comments
 (0)