Message ID | 20220625122502.68095-5-deller@gmx.de (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | fbcon: Fixes for screen resolution changes | expand |
On Sat, Jun 25, 2022 at 02:25:02PM +0200, Helge Deller wrote: > Make sure that we catch, report and fix up fbdev and drm graphic drivers which > got the virtual screen resolution smaller than the physical screen resolution. > > Signed-off-by: Helge Deller <deller@gmx.de> > Cc: stable@vger.kernel.org # v5.4+ No cc: stable for this, it's not fixing any bugs just helps validate driver code. Also if you just move the check from the ioctl code to here we don't need to duplicate anything (and drivers which don't check their set_var are kinda busted no matter what). -Daniel > --- > drivers/video/fbdev/core/fbmem.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c > index 50fb66b954d6..6d262e341023 100644 > --- a/drivers/video/fbdev/core/fbmem.c > +++ b/drivers/video/fbdev/core/fbmem.c > @@ -1006,6 +1006,12 @@ fb_set_var(struct fb_info *info, struct fb_var_screeninfo *var) > if (var->xres < 8 || var->yres < 8) > return -EINVAL; > > + /* make sure virtual resolution >= physical resolution */ > + if (WARN_ON(var->xres_virtual < var->xres)) > + var->xres_virtual = var->xres; > + if (WARN_ON(var->yres_virtual < var->yres)) > + var->yres_virtual = var->yres; > + > /* Too huge resolution causes multiplication overflow. */ > if (check_mul_overflow(var->xres, var->yres, &unused) || > check_mul_overflow(var->xres_virtual, var->yres_virtual, &unused)) > -- > 2.35.3 >
On 6/25/22 15:03, Daniel Vetter wrote: > On Sat, Jun 25, 2022 at 02:25:02PM +0200, Helge Deller wrote: >> Make sure that we catch, report and fix up fbdev and drm graphic drivers which >> got the virtual screen resolution smaller than the physical screen resolution. >> >> Signed-off-by: Helge Deller <deller@gmx.de> >> Cc: stable@vger.kernel.org # v5.4+ > > No cc: stable for this, it's not fixing any bugs just helps validate > driver code. Ok. > Also if you just move the check from the ioctl code to here we don't need > to duplicate anything (and drivers which don't check their set_var are > kinda busted no matter what). See previous mail. We need to decide which way we go, then I'll change it. Thanks! Helge > -Daniel > >> --- >> drivers/video/fbdev/core/fbmem.c | 6 ++++++ >> 1 file changed, 6 insertions(+) >> >> diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c >> index 50fb66b954d6..6d262e341023 100644 >> --- a/drivers/video/fbdev/core/fbmem.c >> +++ b/drivers/video/fbdev/core/fbmem.c >> @@ -1006,6 +1006,12 @@ fb_set_var(struct fb_info *info, struct fb_var_screeninfo *var) >> if (var->xres < 8 || var->yres < 8) >> return -EINVAL; >> >> + /* make sure virtual resolution >= physical resolution */ >> + if (WARN_ON(var->xres_virtual < var->xres)) >> + var->xres_virtual = var->xres; >> + if (WARN_ON(var->yres_virtual < var->yres)) >> + var->yres_virtual = var->yres; >> + >> /* Too huge resolution causes multiplication overflow. */ >> if (check_mul_overflow(var->xres, var->yres, &unused) || >> check_mul_overflow(var->xres_virtual, var->yres_virtual, &unused)) >> -- >> 2.35.3 >> >
diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c index 50fb66b954d6..6d262e341023 100644 --- a/drivers/video/fbdev/core/fbmem.c +++ b/drivers/video/fbdev/core/fbmem.c @@ -1006,6 +1006,12 @@ fb_set_var(struct fb_info *info, struct fb_var_screeninfo *var) if (var->xres < 8 || var->yres < 8) return -EINVAL; + /* make sure virtual resolution >= physical resolution */ + if (WARN_ON(var->xres_virtual < var->xres)) + var->xres_virtual = var->xres; + if (WARN_ON(var->yres_virtual < var->yres)) + var->yres_virtual = var->yres; + /* Too huge resolution causes multiplication overflow. */ if (check_mul_overflow(var->xres, var->yres, &unused) || check_mul_overflow(var->xres_virtual, var->yres_virtual, &unused))
Make sure that we catch, report and fix up fbdev and drm graphic drivers which got the virtual screen resolution smaller than the physical screen resolution. Signed-off-by: Helge Deller <deller@gmx.de> Cc: stable@vger.kernel.org # v5.4+ --- drivers/video/fbdev/core/fbmem.c | 6 ++++++ 1 file changed, 6 insertions(+) -- 2.35.3