[PATCH 1/1] drm/vmwgfx: avoid possible NULL pointer dereference

Heinrich Schuchardt xypron.glpk at gmx.de
Sun Aug 21 21:16:17 UTC 2016


The comment describing function vmw_cmd_res_reloc_add
explicitely mentions p_val may be NULL.

We should not assign a value (NULL) to *p_val in this case.

Signed-off-by: Heinrich Schuchardt <xypron.glpk at gmx.de>
---
 drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
index dc5beff..0363989 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
@@ -652,7 +652,11 @@ static int vmw_cmd_res_reloc_add(struct vmw_private *dev_priv,
 	int ret;
 	struct vmw_resource_val_node *node;
 
+	if (!p_val)
+		return;
+
 	*p_val = NULL;
+
 	ret = vmw_resource_relocation_add(&sw_context->res_relocations,
 					  res,
 					  id_loc - sw_context->buf_start);
@@ -663,8 +667,7 @@ static int vmw_cmd_res_reloc_add(struct vmw_private *dev_priv,
 	if (unlikely(ret != 0))
 		return ret;
 
-	if (p_val)
-		*p_val = node;
+	*p_val = node;
 
 	return 0;
 }
-- 
2.1.4



More information about the dri-devel mailing list