Skip to contentSkip to conversation

drm/vmwgfx: prevent memory leak in vmw_context_define

PATCH In review Navid Emamdoost 2 participants 2 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_context_define

In vmw_context_define if vmw_context_init fails the allocated resource should be unreferenced. The goto label was fixed.

---
 drivers/gpu/drm/vmwgfx/vmwgfx_context.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/vmwgfx/vmwgfx_context.c +1 -1
index a56c9d802382..ac42f8a6acf0 100644
@@ -773,7 +773,7 @@ static int vmw_context_define(struct drm_device *dev, void *data,
 
 	ret = vmw_context_init(dev_priv, res, vmw_user_context_free, dx);
 	if (unlikely(ret != 0))
-		goto out_unlock;
+		goto out_err;
 
 	tmp = vmw_resource_reference(&ctx->res);
 	ret = ttm_base_object_init(tfile, &ctx->base, false, VMW_RES_CONTEXT,
Signature · 1 line
2.17.1
#1 lore raw
Quoted 13 lines · Navid Emamdoost

In vmw_context_define if vmw_context_init fails the allocated resource should be unreferenced. The goto label was fixed.

---
 drivers/gpu/drm/vmwgfx/vmwgfx_context.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/vmwgfx/vmwgfx_context.c +0 -0
index a56c9d802382..ac42f8a6acf0 100644

drivers/gpu/drm/vmwgfx/vmwgfx_context.c static int vmw_context_define(struct drm_device *dev, void *data, · line 779

Quoted 8 lines
drivers/gpu/drm/vmwgfx/vmwgfx_context.c +1 -1
@@ -773,7 +773,7 @@ static int vmw_context_define(struct drm_device *dev, void *data,
 
 	ret = vmw_context_init(dev_priv, res, vmw_user_context_free, dx);
 	if (unlikely(ret != 0))
-		goto out_unlock;
+		goto out_err;
 
 	tmp = vmw_resource_reference(&ctx->res);
 	ret = ttm_base_object_init(tfile, &ctx->base, false, VMW_RES_CONTEXT,

This patch doesn't look correct. vmw_context_init should free up all resources if failing.

Thanks,

Thomas

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