]> git.baikalelectronics.ru Git - kernel.git/commitdiff
fbdev: lxfb: Fix potential divide by zero
authorWei Chen <harperchen1110@gmail.com>
Wed, 15 Mar 2023 09:05:18 +0000 (09:05 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 5 Apr 2023 09:16:43 +0000 (11:16 +0200)
[ Upstream commit 61ac4b86a4c047c20d5cb423ddd87496f14d9868 ]

var->pixclock can be assigned to zero by user. Without proper
check, divide by zero would occur in lx_set_clock.

Error out if var->pixclock is zero.

Signed-off-by: Wei Chen <harperchen1110@gmail.com>
Signed-off-by: Helge Deller <deller@gmx.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/video/fbdev/geode/lxfb_core.c

index b0f07d676eb3e8f6afafb02e917ef95c28abc6dd..ffda25089e2ce42ab49899c1becbb4d9559b157f 100644 (file)
@@ -234,6 +234,9 @@ static void get_modedb(struct fb_videomode **modedb, unsigned int *size)
 
 static int lxfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
 {
+       if (!var->pixclock)
+               return -EINVAL;
+
        if (var->xres > 1920 || var->yres > 1440)
                return -EINVAL;