Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/vmwgfx: prevent memory leak in vmw_cmdbuf_res_add

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>

authored by

Navid Emamdoost and committed by
Thomas Hellstrom
40efb09a 0d4c19f9

+3 -1
+3 -1
drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c
··· 209 209 210 210 cres->hash.key = user_key | (res_type << 24); 211 211 ret = drm_ht_insert_item(&man->resources, &cres->hash); 212 - if (unlikely(ret != 0)) 212 + if (unlikely(ret != 0)) { 213 + kfree(cres); 213 214 goto out_invalid_key; 215 + } 214 216 215 217 cres->state = VMW_CMDBUF_RES_ADD; 216 218 cres->res = vmw_resource_reference(res);