[PATCH] Backport commit bcd6aa7b6cbf ("drm/vmwgfx: NULL pointer dereference from vmw_cmd_dx_view_define()") to linux-5.1-stable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Commit bcd6aa7b6cbf ("drm/vmwgfx: NULL pointer dereference
from vmw_cmd_dx_view_define()") upstream.

That commit resolved a NULL pointer dereference in vmw_view_add(),
which occurred if SVGA_3D_CMD_DX_DEFINE_RENDERTARGET_VIEW was
called with a surface ID of SVGA3D_INVALID_ID.

(The original patch failed to apply cleanly in 5.1-stable
as VMW_DEBUG_USER does not exist here.)

Signed-off-by: Murray McAllister <murray.mcallister@xxxxxxxxx>
---
 drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
index 88b8178d4687..805442947143 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
@@ -2574,6 +2574,10 @@ static int vmw_cmd_dx_view_define(struct vmw_private *dev_priv,
 	if (view_type == vmw_view_max)
 		return -EINVAL;
 	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,
 				user_surface_converter,
 				&cmd->sid, &srf);
-- 
2.20.1




[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux