linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/vmwgfx: prevent memory leak in vmw_cmdbuf_res_add
@ 2019-09-25  4:37 Navid Emamdoost
  2019-11-21 18:17 ` Navid Emamdoost
  2019-12-11 10:19 ` Thomas Hellstrom
  0 siblings, 2 replies; 4+ messages in thread
From: Navid Emamdoost @ 2019-09-25  4:37 UTC (permalink / raw)
  Cc: emamd001, kjlu, smccaman, Navid Emamdoost, VMware Graphics,
	Thomas Hellstrom, David Airlie, Daniel Vetter, dri-devel,
	linux-kernel

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

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

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c b/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c
index 4ac55fc2bf97..44d858ce4ce7 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c
@@ -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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm/vmwgfx: prevent memory leak in vmw_cmdbuf_res_add
  2019-09-25  4:37 [PATCH] drm/vmwgfx: prevent memory leak in vmw_cmdbuf_res_add Navid Emamdoost
@ 2019-11-21 18:17 ` Navid Emamdoost
  2019-12-11  2:33   ` Navid Emamdoost
  2019-12-11 10:19 ` Thomas Hellstrom
  1 sibling, 1 reply; 4+ messages in thread
From: Navid Emamdoost @ 2019-11-21 18:17 UTC (permalink / raw)
  To: VMware Graphics, Thomas Hellstrom, David Airlie, Daniel Vetter,
	dri-devel
  Cc: Navid Emamdoost, LKML

On Tue, Sep 24, 2019 at 11:38 PM Navid Emamdoost
<navid.emamdoost@gmail.com> wrote:
>
> In vmw_cmdbuf_res_add if drm_ht_insert_item fails the allocated memory
> for cres should be released.
>
> Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>

Would you please review this patch?

Thanks,

> ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c b/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c
> index 4ac55fc2bf97..44d858ce4ce7 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c
> @@ -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
>


-- 
Navid.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm/vmwgfx: prevent memory leak in vmw_cmdbuf_res_add
  2019-11-21 18:17 ` Navid Emamdoost
@ 2019-12-11  2:33   ` Navid Emamdoost
  0 siblings, 0 replies; 4+ messages in thread
From: Navid Emamdoost @ 2019-12-11  2:33 UTC (permalink / raw)
  To: VMware Graphics, Thomas Hellstrom, David Airlie, Daniel Vetter,
	dri-devel
  Cc: Navid Emamdoost, LKML

ping ...

On Thu, Nov 21, 2019 at 12:17 PM Navid Emamdoost
<navid.emamdoost@gmail.com> wrote:
>
> On Tue, Sep 24, 2019 at 11:38 PM Navid Emamdoost
> <navid.emamdoost@gmail.com> wrote:
> >
> > In vmw_cmdbuf_res_add if drm_ht_insert_item fails the allocated memory
> > for cres should be released.
> >
> > Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
>
> Would you please review this patch?
>
> Thanks,
>
> > ---
> >  drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c b/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c
> > index 4ac55fc2bf97..44d858ce4ce7 100644
> > --- a/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c
> > +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c
> > @@ -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
> >
>
>
> --
> Navid.



-- 
Navid.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm/vmwgfx: prevent memory leak in vmw_cmdbuf_res_add
  2019-09-25  4:37 [PATCH] drm/vmwgfx: prevent memory leak in vmw_cmdbuf_res_add Navid Emamdoost
  2019-11-21 18:17 ` Navid Emamdoost
@ 2019-12-11 10:19 ` Thomas Hellstrom
  1 sibling, 0 replies; 4+ messages in thread
From: Thomas Hellstrom @ 2019-12-11 10:19 UTC (permalink / raw)
  To: Navid Emamdoost
  Cc: emamd001, kjlu, smccaman, Linux-graphics-maintainer,
	David Airlie, Daniel Vetter, dri-devel, linux-kernel

On 9/25/19 6:38 AM, Navid Emamdoost wrote:
> In vmw_cmdbuf_res_add if drm_ht_insert_item fails the allocated memory
> for cres should be released.
>
> Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
> ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c b/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c
> index 4ac55fc2bf97..44d858ce4ce7 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c
> @@ -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);

Reviewed-by: Thomas Hellstrom <thellstrom@vmware.com>

Will be part of next vmwgfx-next pull.

Thanks,

Thomas



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-12-11 10:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-25  4:37 [PATCH] drm/vmwgfx: prevent memory leak in vmw_cmdbuf_res_add Navid Emamdoost
2019-11-21 18:17 ` Navid Emamdoost
2019-12-11  2:33   ` Navid Emamdoost
2019-12-11 10:19 ` Thomas Hellstrom

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).