From: Jon Mason <jon.ma...@arm.com>

__fill_var is used by both drm_fb_helper_check_var and
drm_fb_helper_fill_var.  In drm_fb_helper_check_var, it is possible that
some of the variables in fb_info-> var which are currently being zero'ed
have pre-existing values.  Zeroing these causes some fb tests to fail
with (from the Xorg.log):

[     9.897] (II) Module fbdevhw: vendor="X.Org Foundation"
[     9.897]    compiled for 1.21.1.8, module version = 0.0.2
[     9.897]    ABI class: X.Org Video Driver, version 25.2
[     9.898] (II) FBDEV(0): using default device
[     9.901] (==) FBDEV(0): Depth 24, (==) framebuffer bpp 32
[     9.902] (==) FBDEV(0): RGB weight 888
[     9.902] (==) FBDEV(0): Default visual is TrueColor
[     9.902] (==) FBDEV(0): Using gamma correction (1.0, 1.0, 1.0)
[     9.902] (II) FBDEV(0): hardware: virtio_gpudrmfb (video memory:
4000kB)
[     9.902] (DB) xf86MergeOutputClassOptions unsupported bus type 0
[     9.903] (II) FBDEV(0): checking modes against framebuffer device...
[     9.904] (II) FBDEV(0):     mode "640x480" test failed
[     9.904] (II) FBDEV(0):     mode "640x480" test failed
[     9.904] (II) FBDEV(0):     mode "640x480" test failed
[     9.904] (II) FBDEV(0):     mode "640x480" test failed
[     9.904] (II) FBDEV(0):     mode "640x480" not found
[     9.904] (II) FBDEV(0): checking modes against monitor...
[     9.905] (II) FBDEV(0): Virtual size is 1280x800 (pitch 1280)
[     9.905] (**) FBDEV(0):  Built-in mode "current"
[     9.905] (==) FBDEV(0): DPI set to (96, 96)

Previously, these values were not modified.  Moving the zero'ing of the
variables to drm_fb_helper_fill_var resolves the issue.

Fixes: ee4cce0a8f03 ("drm/fb-helper: fix input validation gaps in check_var")
Signed-off-by: Jon Mason <jon.ma...@arm.com>
---
 drivers/gpu/drm/drm_fb_helper.c | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index fd27f1978635..ddc12c080dcc 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -1548,8 +1548,6 @@ static void drm_fb_helper_fill_pixel_fmt(struct 
fb_var_screeninfo *var,
 static void __fill_var(struct fb_var_screeninfo *var, struct fb_info *info,
                       struct drm_framebuffer *fb)
 {
-       int i;
-
        var->xres_virtual = fb->width;
        var->yres_virtual = fb->height;
        var->accel_flags = 0;
@@ -1557,15 +1555,6 @@ static void __fill_var(struct fb_var_screeninfo *var, 
struct fb_info *info,
 
        var->height = info->var.height;
        var->width = info->var.width;
-
-       var->left_margin = var->right_margin = 0;
-       var->upper_margin = var->lower_margin = 0;
-       var->hsync_len = var->vsync_len = 0;
-       var->sync = var->vmode = 0;
-       var->rotate = 0;
-       var->colorspace = 0;
-       for (i = 0; i < 4; i++)
-               var->reserved[i] = 0;
 }
 
 /**
@@ -2059,6 +2048,7 @@ static void drm_fb_helper_fill_var(struct fb_info *info,
 {
        struct drm_framebuffer *fb = fb_helper->fb;
        const struct drm_format_info *format = fb->format;
+       int i;
 
        switch (format->format) {
        case DRM_FORMAT_C1:
@@ -2076,6 +2066,14 @@ static void drm_fb_helper_fill_var(struct fb_info *info,
        info->pseudo_palette = fb_helper->pseudo_palette;
        info->var.xoffset = 0;
        info->var.yoffset = 0;
+       info->var.left_margin = info->var.right_margin = 0;
+       info->var.upper_margin = info->var.lower_margin = 0;
+       info->var.hsync_len = info->var.vsync_len = 0;
+       info->var.sync = info->var.vmode = 0;
+       info->var.rotate = 0;
+       info->var.colorspace = 0;
+       for (i = 0; i < 4; i++)
+               info->var.reserved[i] = 0;
        __fill_var(&info->var, info, fb);
        info->var.activate = FB_ACTIVATE_NOW;
 
-- 
2.30.2

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#12944): 
https://lists.yoctoproject.org/g/linux-yocto/message/12944
Mute This Topic: https://lists.yoctoproject.org/mt/100630659/21656
Group Owner: linux-yocto+ow...@lists.yoctoproject.org
Unsubscribe: https://lists.yoctoproject.org/g/linux-yocto/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to