Skip to content

Commit e79d85c

Browse files
geertuThomas Zimmermann
authored andcommitted
drm/fb-helper: Fix height, width, and accel_flags in fb_var
Fbtest contains some very simple validation of the fbdev userspace API contract. When used with shmob-drm, it reports the following warnings and errors: height changed from 68 to 0 height was rounded down width changed from 111 to 0 width was rounded down accel_flags changed from 0 to 1 The first part happens because __fill_var() resets the physical dimensions of the first connector, as filled in by drm_setup_crtcs_fb(). Fix this by retaining the original values. The last part happens because __fill_var() forces the FB_ACCELF_TEXT flag on, while fbtest disables all acceleration on purpose, so it can draw safely to the frame buffer. Fix this by setting accel_flags to zero, as DRM does not implement any text console acceleration. Note that this issue can also be seen in the output of fbset, which reports "accel true". Fixes: ee4cce0 ("drm/fb-helper: fix input validation gaps in check_var") Signed-off-by: Geert Uytterhoeven <[email protected]> Reviewed-by: Daniel Vetter <[email protected]> Tested-by: Sui Jingfeng <[email protected]> Signed-off-by: Thomas Zimmermann <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/57e6b334dae8148b1b8ae6ef308ce9a83810a850.1684854344.git.geert+renesas@glider.be
1 parent e997c21 commit e79d85c

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

drivers/gpu/drm/drm_fb_helper.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1545,17 +1545,19 @@ static void drm_fb_helper_fill_pixel_fmt(struct fb_var_screeninfo *var,
15451545
}
15461546
}
15471547

1548-
static void __fill_var(struct fb_var_screeninfo *var,
1548+
static void __fill_var(struct fb_var_screeninfo *var, struct fb_info *info,
15491549
struct drm_framebuffer *fb)
15501550
{
15511551
int i;
15521552

15531553
var->xres_virtual = fb->width;
15541554
var->yres_virtual = fb->height;
1555-
var->accel_flags = FB_ACCELF_TEXT;
1555+
var->accel_flags = 0;
15561556
var->bits_per_pixel = drm_format_info_bpp(fb->format, 0);
15571557

1558-
var->height = var->width = 0;
1558+
var->height = info->var.height;
1559+
var->width = info->var.width;
1560+
15591561
var->left_margin = var->right_margin = 0;
15601562
var->upper_margin = var->lower_margin = 0;
15611563
var->hsync_len = var->vsync_len = 0;
@@ -1618,7 +1620,7 @@ int drm_fb_helper_check_var(struct fb_var_screeninfo *var,
16181620
return -EINVAL;
16191621
}
16201622

1621-
__fill_var(var, fb);
1623+
__fill_var(var, info, fb);
16221624

16231625
/*
16241626
* fb_pan_display() validates this, but fb_set_par() doesn't and just
@@ -2074,7 +2076,7 @@ static void drm_fb_helper_fill_var(struct fb_info *info,
20742076
info->pseudo_palette = fb_helper->pseudo_palette;
20752077
info->var.xoffset = 0;
20762078
info->var.yoffset = 0;
2077-
__fill_var(&info->var, fb);
2079+
__fill_var(&info->var, info, fb);
20782080
info->var.activate = FB_ACTIVATE_NOW;
20792081

20802082
drm_fb_helper_fill_pixel_fmt(&info->var, format);

0 commit comments

Comments
 (0)