diff mbox series

drm/vmwgfx: prevent memory leak in vmw_context_define

Message ID 20190925044627.2476-1-navid.emamdoost@gmail.com (mailing list archive)
State New, archived
Headers show
Series drm/vmwgfx: prevent memory leak in vmw_context_define | expand

Commit Message

Navid Emamdoost Sept. 25, 2019, 4:46 a.m. UTC
In vmw_context_define if vmw_context_init fails the allocated resource
should be unreferenced. The goto label was fixed.

Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
---
 drivers/gpu/drm/vmwgfx/vmwgfx_context.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Thomas Hellstrom Dec. 11, 2019, 10:20 a.m. UTC | #1
On 9/25/19 6:46 AM, Navid Emamdoost wrote:
> In vmw_context_define if vmw_context_init fails the allocated resource
> should be unreferenced. The goto label was fixed.
>
> Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
> ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_context.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_context.c b/drivers/gpu/drm/vmwgfx/vmwgfx_context.c
> index a56c9d802382..ac42f8a6acf0 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_context.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_context.c
> @@ -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
diff mbox series

Patch

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_context.c b/drivers/gpu/drm/vmwgfx/vmwgfx_context.c
index a56c9d802382..ac42f8a6acf0 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_context.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_context.c
@@ -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,