mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Helge Deller <deller@gmx.de>
To: Zhang Shurong <zhang_shurong@foxmail.com>, daniel@ffwll.ch
Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] fbdev: fbmon: fix potential divide error in fb_validate_mode
Date: Mon, 16 Oct 2023 23:15:28 +0200	[thread overview]
Message-ID: <34994a3f-e44d-4ef1-95ee-2b2a885b3732@gmx.de> (raw)
In-Reply-To: <tencent_C816151C508524D86E346A69B706C0D03C09@qq.com>

On 10/14/23 14:14, Zhang Shurong wrote:
> We can easily use FBIOPUT_VSCREENINFO set fb_var_screeninfo, so
> it's possible for a divide by zero error to occur.
>
> Fix this by making sure the divisor is non-zero before the computation.
>
> Signed-off-by: Zhang Shurong <zhang_shurong@foxmail.com>
> ---
>   drivers/video/fbdev/core/fbmon.c | 3 +++
>   1 file changed, 3 insertions(+)
>
> diff --git a/drivers/video/fbdev/core/fbmon.c b/drivers/video/fbdev/core/fbmon.c
> index 79e5bfbdd34c..bdd15b8e3a71 100644
> --- a/drivers/video/fbdev/core/fbmon.c
> +++ b/drivers/video/fbdev/core/fbmon.c
> @@ -1470,6 +1470,9 @@ int fb_validate_mode(const struct fb_var_screeninfo *var, struct fb_info *info)
>   	if (var->vmode & FB_VMODE_DOUBLE)
>   		vtotal *= 2;
>
> +	if (!htotal || !vtotal)
> +		return -EINVAL;

This is above here:
         htotal = var->xres + var->right_margin + var->hsync_len +
                 var->left_margin;
         vtotal = var->yres + var->lower_margin + var->vsync_len +
                 var->upper_margin;

I don't see how htotal and vtotal can become zero...

Helge

      reply	other threads:[~2023-10-16 21:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-14 12:14 Zhang Shurong
2023-10-16 21:15 ` Helge Deller [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=34994a3f-e44d-4ef1-95ee-2b2a885b3732@gmx.de \
    --to=deller@gmx.de \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=zhang_shurong@foxmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®