[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMuHMdW5wU1ForGOGD-+HDUu7wcnBx3jx911nLEqbJ71t4MBsg@mail.gmail.com>
Date: Tue, 10 Jun 2025 09:42:05 +0200
From: Geert Uytterhoeven <geert@...ux-m68k.org>
To: Alex Guo <alexguo1023@...il.com>
Cc: deller@....de, linux-fbdev@...r.kernel.org,
dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] fbdev: pm3fb: Fix potential divide by zero
Hi Alex,
On Sat, 7 Jun 2025 at 22:14, Alex Guo <alexguo1023@...il.com> wrote:
> variable var->pixclock can be set by user. In case it equals to
> zero, divide by zero would occur in pm3fb_check_var. Similar
> crashes have happened in other fbdev drivers. There is no check
> and modification on var->pixclock along the call chain to
> pm3fb_check_var. So we fix this by checking whether 'pixclock'
> is zero.
>
> Similar commit: commit 16844e58704 ("video: fbdev: tridentfb:
> Error out if 'pixclock' equals zero")
>
> Signed-off-by: Alex Guo <alexguo1023@...il.com>
Thanks for your patch, which is now commit 59d1fc7b3e1ae9d4
("fbdev: pm3fb: fix potential divide by zero") in fbdev/for-next.
> --- a/drivers/video/fbdev/pm3fb.c
> +++ b/drivers/video/fbdev/pm3fb.c
> @@ -998,6 +998,9 @@ static int pm3fb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
> return -EINVAL;
> }
>
> + if (!var->pixclock)
> + return -EINVAL;
While this fixes the crash, this is correct behavior for an fbdev driver.
When a value is invalid, it should be rounded up to a valid value instead,
if possible.
> +
> if (PICOS2KHZ(var->pixclock) > PM3_MAX_PIXCLOCK) {
> DPRINTK("pixclock too high (%ldKHz)\n",
> PICOS2KHZ(var->pixclock));
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@...ux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Powered by blists - more mailing lists