Skip to contentSkip to conversation

drm/vmwgfx: prevent memory leak in vmw_cmdbuf_res_add

PATCH In review Navid Emamdoost 2 participants 4 messages Sep 25, 2019 – Dec 11, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c +3 -1
index 4ac55fc2bf97..44d858ce4ce7 100644
@@ -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);
Signature · 1 line
2.17.1
#1 lore raw
Quoted 5 lines · Navid Emamdoost

In vmw_cmdbuf_res_add if drm_ht_insert_item fails the allocated memory for cres should be released.

Would you please review this patch?

Thanks,

Quoted 23 lines
---
 drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c +3 -2
index 4ac55fc2bf97..44d858ce4ce7 100644
@@ -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);
--

2.17.1

Signature · 1 line
Navid.
#2 lore raw

ping ...

Quoted 40 lines · Navid Emamdoost
Quoted 5 lines · Navid Emamdoost

In vmw_cmdbuf_res_add if drm_ht_insert_item fails the allocated memory for cres should be released.

Would you please review this patch?

Thanks,

Quoted 21 lines
---
 drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c +3 -2
index 4ac55fc2bf97..44d858ce4ce7 100644
@@ -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);
--
Quoted 2 lines

2.17.1

--
Navid.

Signature · 1 line
Navid.
Reviewed-by on v1 1/1
#3 lore raw
In reply to Navid Emamdoost
Quoted 14 lines · Navid Emamdoost

In vmw_cmdbuf_res_add if drm_ht_insert_item fails the allocated memory for cres should be released.

---
 drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c +0 -0
index 4ac55fc2bf97..44d858ce4ce7 100644
@@ -209,8 +209,10 @@ int vmw_cmdbuf_res_add(struct vmw_cmdbuf_res_manager *man,
 

drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c int vmw_cmdbuf_res_add(struct vmw_cmdbuf_res_manager *man, · line 218

Quoted 10 lines
drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c +3 -1
 	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);

Will be part of next vmwgfx-next pull.

Thanks,

Thomas

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel