Skip to content

Commit 58fa0d9

Browse files
zackrThomas Zimmermann
authored andcommitted
drm/vmwgfx: Fix possible usage of an uninitialized variable
vmw_user_bo_lookup can fail to lookup user buffers, especially because the buffer handles come from the userspace. The return value has to be checked before the buffers are put back. This was spotted by Dan's Smatch statick checker: drivers/gpu/drm/vmwgfx/vmwgfx_bo.c:574 vmw_user_bo_synccpu_release() error: uninitialized symbol 'vmw_bo'. Signed-off-by: Zack Rusin <[email protected]> Reported-by: Dan Carpenter <[email protected]> Fixes: 8afa13a ("drm/vmwgfx: Implement DRIVER_GEM") Reviewed-by: Martin Krastev <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] (cherry picked from commit 60c9ecd) Signed-off-by: Thomas Zimmermann <[email protected]>
1 parent 50ca8cc commit 58fa0d9

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

drivers/gpu/drm/vmwgfx/vmwgfx_bo.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -568,10 +568,12 @@ static int vmw_user_bo_synccpu_release(struct drm_file *filp,
568568
struct vmw_buffer_object *vmw_bo;
569569
int ret = vmw_user_bo_lookup(filp, handle, &vmw_bo);
570570

571-
if (!(flags & drm_vmw_synccpu_allow_cs)) {
572-
atomic_dec(&vmw_bo->cpu_writers);
571+
if (!ret) {
572+
if (!(flags & drm_vmw_synccpu_allow_cs)) {
573+
atomic_dec(&vmw_bo->cpu_writers);
574+
}
575+
ttm_bo_put(&vmw_bo->base);
573576
}
574-
ttm_bo_put(&vmw_bo->base);
575577

576578
return ret;
577579
}

0 commit comments

Comments
 (0)