Linux Framebuffer Layer development
 help / color / mirror / Atom feed
From: Helge Deller <deller@gmx.de>
To: Geert Uytterhoeven <geert@linux-m68k.org>,
	Jianqiang Zou <jq.zou@outlook.com>
Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 1/2] fbdev: radeonfb: reject a zero pixclock in radeonfb_check_var()
Date: Mon, 23 Nov 2026 17:09:57 +0100	[thread overview]
Message-ID: <a2ffabc2-4096-4767-8124-c77e5dd79564@gmx.de> (raw)
In-Reply-To: <CAMuHMdWyrdpVKvs=8Q+B-Syo1ZdAJvfJXFv0qiNtR9z4VnwnBQ@mail.gmail.com>

On 11/23/26 08:52, Geert Uytterhoeven wrote:
> Hi Helge, Jianqiang,
> 
> On Fri, 20 Nov 2026 at 18:54, Helge Deller <deller@gmx.de> wrote:
>> From: Jianqiang Zou <jq.zou@outlook.com>
>>
>> radeonfb_set_par() derives the dot clock from the user supplied
>> struct fb_var_screeninfo:
>>
>>          dotClock = 1000000000 / pixClock;
>>
>> where pixClock is copied from mode->pixclock.  A zero pixclock
>> bypasses the existing validation and makes the kernel divide by zero
>> in radeonfb_set_par().
>>
>> The driver does have a check for this: fb_validate_mode() returns
>> -EINVAL when pixclock is 0, but radeon_match_mode() only calls it when
>> the output has no scaler and an EDID-derived mode database is
>> available:
>>
>>          if (has_rmx == 0 && rinfo->mon1_modedb)
>>                  if (fb_validate_mode(...))
>>                          return -EINVAL;
>>
>> mon1_modedb is only filled in when an EDID is read, so when no
>> EDID-derived mode database is available the validation is skipped and
>> the invalid mode reaches radeonfb_set_par().
>>
>> Reject a zero pixclock in radeonfb_check_var() before matching the
>> mode.  fb_set_var() calls it on the FBIOPUT_VSCREENINFO path before
>> ->fb_set_par(), so the invalid value is rejected before the mode is
>> applied.  This is the same check other fbdev drivers use (i740fb,
>> arkfb, s3fb).
>>
>> Reproduced on Linux 7.3.0 using a custom QEMU PCI stub device with
>> vendor/device ID 1002:5955; no physical Radeon hardware was used.  A
>> single FBIOPUT_VSCREENINFO with pixclock = 0 is enough to trigger the
>> divide error.
>>
>> Signed-off-by: Jianqiang Zou <jq.zou@outlook.com>
>> Cc: stable@vger.kernel.org
>> Signed-off-by: Helge Deller <deller@gmx.de>
> 
> Thanks for your patch, which is now commit b3f1631d362539cf ("fbdev:
> radeonfb: reject a zero pixclock in radeonfb_check_var()") in v7.4-rc4.
> 
> 
>> --- a/drivers/video/fbdev/aty/radeon_base.c
>> +++ b/drivers/video/fbdev/aty/radeon_base.c
>> @@ -836,6 +836,9 @@ static int radeonfb_check_var (struct fb_var_screeninfo *var, struct fb_info *in
>>           int nom, den;
>>          unsigned int pitch;
>>
>> +       if (!var->pixclock)
>> +               return -EINVAL;
>> +
> 
> This violates fbdev API rounding rules:
>    1. If a value doesn't fit, it must be rounded up by the driver,
>    2. If a value is too large, -EINVAL must be returned.
> 
>>          if (radeon_match_mode(rinfo, &v, var))
>>                  return -EINVAL;
Oops... you are right!
Jianqiang Zou, will you send another patch fixing this?

Helge

      reply	other threads:[~2026-11-23 16:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20 17:54 [PATCH 1/2] fbdev: radeonfb: reject a zero pixclock in radeonfb_check_var() Helge Deller
2026-11-20 17:54 ` [PATCH 2/2] fbcon: Don't drop last logo line if logo is same size as screen Helge Deller
2026-11-23  7:52 ` [PATCH 1/2] fbdev: radeonfb: reject a zero pixclock in radeonfb_check_var() Geert Uytterhoeven
2026-11-23 16:09   ` 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=a2ffabc2-4096-4767-8124-c77e5dd79564@gmx.de \
    --to=deller@gmx.de \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=geert@linux-m68k.org \
    --cc=jq.zou@outlook.com \
    --cc=linux-fbdev@vger.kernel.org \
    /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