Commit 83451ede authored by Murray McAllister's avatar Murray McAllister Committed by Stefan Bader

drm/vmwgfx: NULL pointer dereference from vmw_cmd_dx_view_define()

BugLink: https://bugs.launchpad.net/bugs/1836666

commit bcd6aa7b upstream.

If SVGA_3D_CMD_DX_DEFINE_RENDERTARGET_VIEW is called with a surface
ID of SVGA3D_INVALID_ID, the srf struct will remain NULL after
vmw_cmd_res_check(), leading to a null pointer dereference in
vmw_view_add().

Cc: <stable@vger.kernel.org>
Fixes: d80efd5c ("drm/vmwgfx: Initial DX support")
Signed-off-by: default avatarMurray McAllister <murray.mcallister@gmail.com>
Reviewed-by: default avatarThomas Hellstrom <thellstrom@vmware.com>
Signed-off-by: default avatarThomas Hellstrom <thellstrom@vmware.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarKhalid Elmously <khalid.elmously@canonical.com>
Signed-off-by: default avatarKleber Sacilotto de Souza <kleber.souza@canonical.com>
parent aa83c0d9
...@@ -2682,6 +2682,10 @@ static int vmw_cmd_dx_view_define(struct vmw_private *dev_priv, ...@@ -2682,6 +2682,10 @@ static int vmw_cmd_dx_view_define(struct vmw_private *dev_priv,
if (view_type == vmw_view_max) if (view_type == vmw_view_max)
return -EINVAL; return -EINVAL;
cmd = container_of(header, typeof(*cmd), header); cmd = container_of(header, typeof(*cmd), header);
if (unlikely(cmd->sid == SVGA3D_INVALID_ID)) {
DRM_ERROR("Invalid surface id.\n");
return -EINVAL;
}
ret = vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface, ret = vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface,
user_surface_converter, user_surface_converter,
&cmd->sid, &srf_node); &cmd->sid, &srf_node);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment