Skip to content

Commit d09eb27

Browse files
jonmasonzeddii
authored andcommitted
drm/fb-helper: move zeroing code to drm_fb_helper_fill_var
__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: ee4cce0 ("drm/fb-helper: fix input validation gaps in check_var") Signed-off-by: Jon Mason <[email protected]> Signed-off-by: Bruce Ashfield <[email protected]>
1 parent 158025e commit d09eb27

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

drivers/gpu/drm/drm_fb_helper.c

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,24 +1190,13 @@ static void drm_fb_helper_fill_pixel_fmt(struct fb_var_screeninfo *var,
11901190
static void __fill_var(struct fb_var_screeninfo *var, struct fb_info *info,
11911191
struct drm_framebuffer *fb)
11921192
{
1193-
int i;
1194-
11951193
var->xres_virtual = fb->width;
11961194
var->yres_virtual = fb->height;
11971195
var->accel_flags = 0;
11981196
var->bits_per_pixel = drm_format_info_bpp(fb->format, 0);
11991197

12001198
var->height = info->var.height;
12011199
var->width = info->var.width;
1202-
1203-
var->left_margin = var->right_margin = 0;
1204-
var->upper_margin = var->lower_margin = 0;
1205-
var->hsync_len = var->vsync_len = 0;
1206-
var->sync = var->vmode = 0;
1207-
var->rotate = 0;
1208-
var->colorspace = 0;
1209-
for (i = 0; i < 4; i++)
1210-
var->reserved[i] = 0;
12111200
}
12121201

12131202
/**
@@ -1701,6 +1690,7 @@ static void drm_fb_helper_fill_var(struct fb_info *info,
17011690
{
17021691
struct drm_framebuffer *fb = fb_helper->fb;
17031692
const struct drm_format_info *format = fb->format;
1693+
int i;
17041694

17051695
switch (format->format) {
17061696
case DRM_FORMAT_C1:
@@ -1718,6 +1708,14 @@ static void drm_fb_helper_fill_var(struct fb_info *info,
17181708
info->pseudo_palette = fb_helper->pseudo_palette;
17191709
info->var.xoffset = 0;
17201710
info->var.yoffset = 0;
1711+
info->var.left_margin = info->var.right_margin = 0;
1712+
info->var.upper_margin = info->var.lower_margin = 0;
1713+
info->var.hsync_len = info->var.vsync_len = 0;
1714+
info->var.sync = info->var.vmode = 0;
1715+
info->var.rotate = 0;
1716+
info->var.colorspace = 0;
1717+
for (i = 0; i < 4; i++)
1718+
info->var.reserved[i] = 0;
17211719
__fill_var(&info->var, info, fb);
17221720
info->var.activate = FB_ACTIVATE_NOW;
17231721

0 commit comments

Comments
 (0)