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

From: Heinrich Schuchardt
Date: Sun Aug 21 2016 - 17:16:38 EST


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@xxxxxx>
---
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