diff options
author | Zack Rusin <zackr@vmware.com> | 2022-10-22 00:02:31 -0400 |
---|---|---|
committer | Zack Rusin <zackr@vmware.com> | 2022-10-25 12:42:27 -0400 |
commit | 1c8d537bbcc9708d667d81ddc2caf43ec753cf05 (patch) | |
tree | d5d7400742c7f753cf40030733c28c695e83cf25 /drivers/gpu/drm/vmwgfx | |
parent | 9da30cdd6a318595199319708c143ae318f804ef (diff) | |
download | linux-stable-1c8d537bbcc9708d667d81ddc2caf43ec753cf05.tar.gz linux-stable-1c8d537bbcc9708d667d81ddc2caf43ec753cf05.tar.bz2 linux-stable-1c8d537bbcc9708d667d81ddc2caf43ec753cf05.zip |
drm/vmwgfx: Do not allow invalid bpp's for dumb buffers
Dumb buffers allow a very limited set of formats. Basically everything
apart from 1, 2 and 4 is expected to return an error. Make vmwgfx
follow those guidelines.
This fixes igt's dumb_buffer invalid_bpp test on vmwgfx.
Signed-off-by: Zack Rusin <zackr@vmware.com>
Reviewed-by: Martin Krastev <krastevm@vmware.com>
Reviewed-by: Maaz Mombasawala <mombasawalam@vmware.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20221022040236.616490-13-zack@kde.org
Diffstat (limited to 'drivers/gpu/drm/vmwgfx')
-rw-r--r-- | drivers/gpu/drm/vmwgfx/vmwgfx_bo.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_bo.c b/drivers/gpu/drm/vmwgfx/vmwgfx_bo.c index 822251aaab0a..d218b15953e0 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_bo.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_bo.c @@ -807,9 +807,23 @@ int vmw_dumb_create(struct drm_file *file_priv, { struct vmw_private *dev_priv = vmw_priv(dev); struct vmw_buffer_object *vbo; + int cpp = DIV_ROUND_UP(args->bpp, 8); int ret; - args->pitch = args->width * ((args->bpp + 7) / 8); + switch (cpp) { + case 1: /* DRM_FORMAT_C8 */ + case 2: /* DRM_FORMAT_RGB565 */ + case 4: /* DRM_FORMAT_XRGB8888 */ + break; + default: + /* + * Dumb buffers don't allow anything else. + * This is tested via IGT's dumb_buffers + */ + return -EINVAL; + } + + args->pitch = args->width * cpp; args->size = ALIGN(args->pitch * args->height, PAGE_SIZE); ret = vmw_gem_object_create_with_handle(dev_priv, file_priv, |