Skip to content

Commit

Permalink
drm/vmwgfx: prevent memory leak in vmw_cmdbuf_res_add
Browse files Browse the repository at this point in the history
In vmw_cmdbuf_res_add if drm_ht_insert_item fails the allocated memory
for cres should be released.

Fixes: 18e4a46 ("drm/vmwgfx: Fix compat shader namespace")
Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
Reviewed-by: Thomas Hellstrom <thellstrom@vmware.com>
Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
  • Loading branch information
Navidem authored and thomashvmw committed Jan 15, 2020
1 parent 0d4c19f commit 40efb09
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,10 @@ int vmw_cmdbuf_res_add(struct vmw_cmdbuf_res_manager *man,

cres->hash.key = user_key | (res_type << 24);
ret = drm_ht_insert_item(&man->resources, &cres->hash);
if (unlikely(ret != 0))
if (unlikely(ret != 0)) {
kfree(cres);
goto out_invalid_key;
}

cres->state = VMW_CMDBUF_RES_ADD;
cres->res = vmw_resource_reference(res);
Expand Down

0 comments on commit 40efb09

Please sign in to comment.