Skip to content

Commit f57eff3

Browse files
Dan Carpenterkerneltoast
authored andcommitted
drm/vmwgfx: clean up some error pointer checking
The vmw_user_bo_noref_lookup() function cannot return NULL. If it could, then this function would return PTR_ERR(NULL) which is success. Returning success without initializing "*vmw_bo_p = vmw_bo;" would lead to an uninitialized variable bug in the caller. Smatch complains about this: drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c:1177 vmw_translate_mob_ptr() warn: passing zero to 'PTR_ERR' drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c:1314 vmw_cmd_dx_bind_query() error: uninitialized symbol 'vmw_bo'. Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Zack Rusin <zackr@vmware.com> Link: https://patchwork.freedesktop.org/patch/msgid/YtZ9qrKeBqmmK8Hv@kili
1 parent 5d5ceb8 commit f57eff3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,7 +1172,7 @@ static int vmw_translate_mob_ptr(struct vmw_private *dev_priv,
11721172

11731173
vmw_validation_preload_bo(sw_context->ctx);
11741174
vmw_bo = vmw_user_bo_noref_lookup(sw_context->filp, handle);
1175-
if (IS_ERR_OR_NULL(vmw_bo)) {
1175+
if (IS_ERR(vmw_bo)) {
11761176
VMW_DEBUG_USER("Could not find or use MOB buffer.\n");
11771177
return PTR_ERR(vmw_bo);
11781178
}
@@ -1226,7 +1226,7 @@ static int vmw_translate_guest_ptr(struct vmw_private *dev_priv,
12261226

12271227
vmw_validation_preload_bo(sw_context->ctx);
12281228
vmw_bo = vmw_user_bo_noref_lookup(sw_context->filp, handle);
1229-
if (IS_ERR_OR_NULL(vmw_bo)) {
1229+
if (IS_ERR(vmw_bo)) {
12301230
VMW_DEBUG_USER("Could not find or use GMR region.\n");
12311231
return PTR_ERR(vmw_bo);
12321232
}

0 commit comments

Comments
 (0)