public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/i915/sprite: Fix mem leak in intel_plane_init()
@ 2012-06-26 22:55 Jesper Juhl
  2012-06-27  0:12 ` Jesse Barnes
  2012-06-27  8:34 ` Chris Wilson
  0 siblings, 2 replies; 4+ messages in thread
From: Jesper Juhl @ 2012-06-26 22:55 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jesse Barnes, dri-devel, David Airlie, Daniel Vetter

If we ever hit the default case in the switch statement we'll return
from the function without freeing the memory we just allocated to
'intel_plane' (but that has not been used).

This patch gets rid of the leak by freeing the memory just before we
return.

Signed-off-by: Jesper Juhl <jj@chaosbits.net>
---
 drivers/gpu/drm/i915/intel_sprite.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c
index 2a20fb0..c8851ba 100644
--- a/drivers/gpu/drm/i915/intel_sprite.c
+++ b/drivers/gpu/drm/i915/intel_sprite.c
@@ -685,6 +685,7 @@ intel_plane_init(struct drm_device *dev, enum pipe pipe)
 		break;
 
 	default:
+		kfree(intel_plane);
 		return -ENODEV;
 	}
 
@@ -699,4 +700,3 @@ intel_plane_init(struct drm_device *dev, enum pipe pipe)
 
 	return ret;
 }
-
-- 
1.7.11.1


-- 
Jesper Juhl <jj@chaosbits.net>       http://www.chaosbits.net/
Don't top-post http://www.catb.org/jargon/html/T/top-post.html
Plain text mails only, please.


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

* Re: [PATCH] drm/i915/sprite: Fix mem leak in intel_plane_init()
  2012-06-26 22:55 [PATCH] drm/i915/sprite: Fix mem leak in intel_plane_init() Jesper Juhl
@ 2012-06-27  0:12 ` Jesse Barnes
  2012-06-27 11:36   ` Daniel Vetter
  2012-06-27  8:34 ` Chris Wilson
  1 sibling, 1 reply; 4+ messages in thread
From: Jesse Barnes @ 2012-06-27  0:12 UTC (permalink / raw)
  To: Jesper Juhl; +Cc: linux-kernel, dri-devel, David Airlie, Daniel Vetter

On Wed, 27 Jun 2012 00:55:37 +0200 (CEST)
Jesper Juhl <jj@chaosbits.net> wrote:

> If we ever hit the default case in the switch statement we'll return
> from the function without freeing the memory we just allocated to
> 'intel_plane' (but that has not been used).
> 
> This patch gets rid of the leak by freeing the memory just before we
> return.
> 
> Signed-off-by: Jesper Juhl <jj@chaosbits.net>
> ---
>  drivers/gpu/drm/i915/intel_sprite.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c
> index 2a20fb0..c8851ba 100644
> --- a/drivers/gpu/drm/i915/intel_sprite.c
> +++ b/drivers/gpu/drm/i915/intel_sprite.c
> @@ -685,6 +685,7 @@ intel_plane_init(struct drm_device *dev, enum pipe pipe)
>  		break;
>  
>  	default:
> +		kfree(intel_plane);
>  		return -ENODEV;
>  	}
>  
> @@ -699,4 +700,3 @@ intel_plane_init(struct drm_device *dev, enum pipe pipe)
>  
>  	return ret;
>  }

Yeah, looks fine.  I just fixed the same thing in a local tree (though
by using a goto since I added another path that could fail).

Reviewed-by: Jesse Barnes <jbarnes@virtuousgeek.org>

-- 
Jesse Barnes, Intel Open Source Technology Center

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

* Re: [PATCH] drm/i915/sprite: Fix mem leak in intel_plane_init()
  2012-06-26 22:55 [PATCH] drm/i915/sprite: Fix mem leak in intel_plane_init() Jesper Juhl
  2012-06-27  0:12 ` Jesse Barnes
@ 2012-06-27  8:34 ` Chris Wilson
  1 sibling, 0 replies; 4+ messages in thread
From: Chris Wilson @ 2012-06-27  8:34 UTC (permalink / raw)
  To: Jesper Juhl, linux-kernel
  Cc: Jesse Barnes, dri-devel, David Airlie, Daniel Vetter

On Wed, 27 Jun 2012 00:55:37 +0200 (CEST), Jesper Juhl <jj@chaosbits.net> wrote:
> If we ever hit the default case in the switch statement we'll return
> from the function without freeing the memory we just allocated to
> 'intel_plane' (but that has not been used).
> 
> This patch gets rid of the leak by freeing the memory just before we
> return.

Heh, I was more worried about the real leak of the planes on module
unload.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre

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

* Re: [PATCH] drm/i915/sprite: Fix mem leak in intel_plane_init()
  2012-06-27  0:12 ` Jesse Barnes
@ 2012-06-27 11:36   ` Daniel Vetter
  0 siblings, 0 replies; 4+ messages in thread
From: Daniel Vetter @ 2012-06-27 11:36 UTC (permalink / raw)
  To: Jesse Barnes
  Cc: Jesper Juhl, linux-kernel, dri-devel, David Airlie, Daniel Vetter

On Tue, Jun 26, 2012 at 05:12:46PM -0700, Jesse Barnes wrote:
> On Wed, 27 Jun 2012 00:55:37 +0200 (CEST)
> Jesper Juhl <jj@chaosbits.net> wrote:
> 
> > If we ever hit the default case in the switch statement we'll return
> > from the function without freeing the memory we just allocated to
> > 'intel_plane' (but that has not been used).
> > 
> > This patch gets rid of the leak by freeing the memory just before we
> > return.
> > 
> > Signed-off-by: Jesper Juhl <jj@chaosbits.net>
> > ---
> >  drivers/gpu/drm/i915/intel_sprite.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c
> > index 2a20fb0..c8851ba 100644
> > --- a/drivers/gpu/drm/i915/intel_sprite.c
> > +++ b/drivers/gpu/drm/i915/intel_sprite.c
> > @@ -685,6 +685,7 @@ intel_plane_init(struct drm_device *dev, enum pipe pipe)
> >  		break;
> >  
> >  	default:
> > +		kfree(intel_plane);
> >  		return -ENODEV;
> >  	}
> >  
> > @@ -699,4 +700,3 @@ intel_plane_init(struct drm_device *dev, enum pipe pipe)
> >  
> >  	return ret;
> >  }
> 
> Yeah, looks fine.  I just fixed the same thing in a local tree (though
> by using a goto since I added another path that could fail).
> 
> Reviewed-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Queued for -next, thanks for the patch.
-Daniel
-- 
Daniel Vetter
Mail: daniel@ffwll.ch
Mobile: +41 (0)79 365 57 48

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

end of thread, other threads:[~2012-06-27 11:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-26 22:55 [PATCH] drm/i915/sprite: Fix mem leak in intel_plane_init() Jesper Juhl
2012-06-27  0:12 ` Jesse Barnes
2012-06-27 11:36   ` Daniel Vetter
2012-06-27  8:34 ` Chris Wilson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox