]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
drm/vmwgfx: prevent memory leak in vmw_cmdbuf_res_add
authorNavid Emamdoost <navid.emamdoost@gmail.com>
Wed, 25 Sep 2019 04:37:58 +0000 (23:37 -0500)
committerThomas Hellstrom <thellstrom@vmware.com>
Wed, 15 Jan 2020 10:46:59 +0000 (11:46 +0100)
In vmw_cmdbuf_res_add if drm_ht_insert_item fails the allocated memory
for cres should be released.

Fixes: 18e4a4669c50 ("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>
drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c

index 4ac55fc2bf97021e36a2035dc5b5a830183c996c..44d858ce4ce7f2f4b047e12ff84986d1b19d2819 100644 (file)
@@ -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);