linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/amd/display: prevent memory leak
@ 2019-09-25  4:23 Navid Emamdoost
  2019-09-25 13:54 ` Harry Wentland
  0 siblings, 1 reply; 3+ messages in thread
From: Navid Emamdoost @ 2019-09-25  4:23 UTC (permalink / raw)
  Cc: emamd001, smccaman, kjlu, Navid Emamdoost, Harry Wentland,
	Leo Li, Alex Deucher, Christian König,
	David (ChunMing) Zhou, David Airlie, Daniel Vetter,
	Bhawanpreet Lakha, Tony Cheng, Dmytro Laktyushkin, Eric Yang,
	Jun Lei, Wesley Chalmers, David Francis, Nicholas Kazlauskas,
	Aidan Wood, Ken Chalmers, Eric Bernstein, hersen wu,
	Sam Ravnborg, Roman Li, Wang Hai, Thomas Lim, Su Sung Chung,
	amd-gfx, dri-devel, linux-kernel

In dcn*_create_resource_pool the allocated memory should be released if
construct pool fails.

Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
---
 drivers/gpu/drm/amd/display/dc/dce100/dce100_resource.c | 1 +
 drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c | 1 +
 drivers/gpu/drm/amd/display/dc/dce112/dce112_resource.c | 1 +
 drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c | 1 +
 drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c   | 1 +
 5 files changed, 5 insertions(+)

diff --git a/drivers/gpu/drm/amd/display/dc/dce100/dce100_resource.c b/drivers/gpu/drm/amd/display/dc/dce100/dce100_resource.c
index afc61055eca1..1787b9bf800a 100644
--- a/drivers/gpu/drm/amd/display/dc/dce100/dce100_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dce100/dce100_resource.c
@@ -1091,6 +1091,7 @@ struct resource_pool *dce100_create_resource_pool(
 	if (construct(num_virtual_links, dc, pool))
 		return &pool->base;
 
+	kfree(pool);
 	BREAK_TO_DEBUGGER();
 	return NULL;
 }
diff --git a/drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c b/drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c
index c66fe170e1e8..318e9c2e2ca8 100644
--- a/drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c
@@ -1462,6 +1462,7 @@ struct resource_pool *dce110_create_resource_pool(
 	if (construct(num_virtual_links, dc, pool, asic_id))
 		return &pool->base;
 
+	kfree(pool);
 	BREAK_TO_DEBUGGER();
 	return NULL;
 }
diff --git a/drivers/gpu/drm/amd/display/dc/dce112/dce112_resource.c b/drivers/gpu/drm/amd/display/dc/dce112/dce112_resource.c
index 3ac4c7e73050..3199d493d13b 100644
--- a/drivers/gpu/drm/amd/display/dc/dce112/dce112_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dce112/dce112_resource.c
@@ -1338,6 +1338,7 @@ struct resource_pool *dce112_create_resource_pool(
 	if (construct(num_virtual_links, dc, pool))
 		return &pool->base;
 
+	kfree(pool);
 	BREAK_TO_DEBUGGER();
 	return NULL;
 }
diff --git a/drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c b/drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c
index 7d08154e9662..bb497f43f6eb 100644
--- a/drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c
@@ -1203,6 +1203,7 @@ struct resource_pool *dce120_create_resource_pool(
 	if (construct(num_virtual_links, dc, pool))
 		return &pool->base;
 
+	kfree(pool);
 	BREAK_TO_DEBUGGER();
 	return NULL;
 }
diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c
index 5a89e462e7cc..59305e411a66 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c
@@ -1570,6 +1570,7 @@ struct resource_pool *dcn10_create_resource_pool(
 	if (construct(init_data->num_virtual_links, dc, pool))
 		return &pool->base;
 
+	kfree(pool);
 	BREAK_TO_DEBUGGER();
 	return NULL;
 }
-- 
2.17.1


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

* Re: [PATCH] drm/amd/display: prevent memory leak
  2019-09-25  4:23 [PATCH] drm/amd/display: prevent memory leak Navid Emamdoost
@ 2019-09-25 13:54 ` Harry Wentland
  2019-09-25 16:04   ` Alex Deucher
  0 siblings, 1 reply; 3+ messages in thread
From: Harry Wentland @ 2019-09-25 13:54 UTC (permalink / raw)
  To: Navid Emamdoost
  Cc: emamd001, smccaman, kjlu, Wentland, Harry, Li, Sun peng (Leo),
	Deucher, Alexander, Koenig, Christian, Zhou, David(ChunMing),
	David Airlie, Daniel Vetter, Lakha, Bhawanpreet, Cheng, Tony,
	Laktyushkin, Dmytro, Yang, Eric, Lei, Jun, Chalmers, Wesley,
	Francis, David, Kazlauskas, Nicholas, Aidan Wood, Chalmers,
	Kenneth, Bernstein, Eric, Wu, Hersen, Sam Ravnborg, Li, Roman,
	Wang Hai, Thomas Lim, Su Sung Chung, amd-gfx, dri-devel,
	linux-kernel



On 2019-09-25 12:23 a.m., Navid Emamdoost wrote:
> In dcn*_create_resource_pool the allocated memory should be released if
> construct pool fails.
> 
> Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>

Reviewed-by: Harry Wentland <harry.wentland@amd.com>

Harry

> ---
>  drivers/gpu/drm/amd/display/dc/dce100/dce100_resource.c | 1 +
>  drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c | 1 +
>  drivers/gpu/drm/amd/display/dc/dce112/dce112_resource.c | 1 +
>  drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c | 1 +
>  drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c   | 1 +
>  5 files changed, 5 insertions(+)
> 
> diff --git a/drivers/gpu/drm/amd/display/dc/dce100/dce100_resource.c b/drivers/gpu/drm/amd/display/dc/dce100/dce100_resource.c
> index afc61055eca1..1787b9bf800a 100644
> --- a/drivers/gpu/drm/amd/display/dc/dce100/dce100_resource.c
> +++ b/drivers/gpu/drm/amd/display/dc/dce100/dce100_resource.c
> @@ -1091,6 +1091,7 @@ struct resource_pool *dce100_create_resource_pool(
>  	if (construct(num_virtual_links, dc, pool))
>  		return &pool->base;
>  
> +	kfree(pool);
>  	BREAK_TO_DEBUGGER();
>  	return NULL;
>  }
> diff --git a/drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c b/drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c
> index c66fe170e1e8..318e9c2e2ca8 100644
> --- a/drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c
> +++ b/drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c
> @@ -1462,6 +1462,7 @@ struct resource_pool *dce110_create_resource_pool(
>  	if (construct(num_virtual_links, dc, pool, asic_id))
>  		return &pool->base;
>  
> +	kfree(pool);
>  	BREAK_TO_DEBUGGER();
>  	return NULL;
>  }
> diff --git a/drivers/gpu/drm/amd/display/dc/dce112/dce112_resource.c b/drivers/gpu/drm/amd/display/dc/dce112/dce112_resource.c
> index 3ac4c7e73050..3199d493d13b 100644
> --- a/drivers/gpu/drm/amd/display/dc/dce112/dce112_resource.c
> +++ b/drivers/gpu/drm/amd/display/dc/dce112/dce112_resource.c
> @@ -1338,6 +1338,7 @@ struct resource_pool *dce112_create_resource_pool(
>  	if (construct(num_virtual_links, dc, pool))
>  		return &pool->base;
>  
> +	kfree(pool);
>  	BREAK_TO_DEBUGGER();
>  	return NULL;
>  }
> diff --git a/drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c b/drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c
> index 7d08154e9662..bb497f43f6eb 100644
> --- a/drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c
> +++ b/drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c
> @@ -1203,6 +1203,7 @@ struct resource_pool *dce120_create_resource_pool(
>  	if (construct(num_virtual_links, dc, pool))
>  		return &pool->base;
>  
> +	kfree(pool);
>  	BREAK_TO_DEBUGGER();
>  	return NULL;
>  }
> diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c
> index 5a89e462e7cc..59305e411a66 100644
> --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c
> +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c
> @@ -1570,6 +1570,7 @@ struct resource_pool *dcn10_create_resource_pool(
>  	if (construct(init_data->num_virtual_links, dc, pool))
>  		return &pool->base;
>  
> +	kfree(pool);
>  	BREAK_TO_DEBUGGER();
>  	return NULL;
>  }
> 

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

* Re: [PATCH] drm/amd/display: prevent memory leak
  2019-09-25 13:54 ` Harry Wentland
@ 2019-09-25 16:04   ` Alex Deucher
  0 siblings, 0 replies; 3+ messages in thread
From: Alex Deucher @ 2019-09-25 16:04 UTC (permalink / raw)
  To: Harry Wentland
  Cc: Navid Emamdoost, David Airlie, dri-devel, linux-kernel, Lei, Jun,
	Sam Ravnborg, Wang Hai, Cheng, Tony, Francis, David, amd-gfx,
	emamd001, Bernstein, Eric, Su Sung Chung, smccaman, Li,
	Sun peng (Leo),
	kjlu, Aidan Wood, Wu, Hersen, Lakha, Bhawanpreet, Chalmers,
	Kenneth, Thomas Lim, Yang, Eric, Chalmers, Wesley, Li, Roman,
	Koenig, Christian, Laktyushkin, Dmytro, Deucher, Alexander,
	Kazlauskas, Nicholas

On Wed, Sep 25, 2019 at 9:54 AM Harry Wentland <hwentlan@amd.com> wrote:
>
>
>
> On 2019-09-25 12:23 a.m., Navid Emamdoost wrote:
> > In dcn*_create_resource_pool the allocated memory should be released if
> > construct pool fails.
> >
> > Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
>
> Reviewed-by: Harry Wentland <harry.wentland@amd.com>
>

Applied.  thanks!

Alex

> Harry
>
> > ---
> >  drivers/gpu/drm/amd/display/dc/dce100/dce100_resource.c | 1 +
> >  drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c | 1 +
> >  drivers/gpu/drm/amd/display/dc/dce112/dce112_resource.c | 1 +
> >  drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c | 1 +
> >  drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c   | 1 +
> >  5 files changed, 5 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/amd/display/dc/dce100/dce100_resource.c b/drivers/gpu/drm/amd/display/dc/dce100/dce100_resource.c
> > index afc61055eca1..1787b9bf800a 100644
> > --- a/drivers/gpu/drm/amd/display/dc/dce100/dce100_resource.c
> > +++ b/drivers/gpu/drm/amd/display/dc/dce100/dce100_resource.c
> > @@ -1091,6 +1091,7 @@ struct resource_pool *dce100_create_resource_pool(
> >       if (construct(num_virtual_links, dc, pool))
> >               return &pool->base;
> >
> > +     kfree(pool);
> >       BREAK_TO_DEBUGGER();
> >       return NULL;
> >  }
> > diff --git a/drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c b/drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c
> > index c66fe170e1e8..318e9c2e2ca8 100644
> > --- a/drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c
> > +++ b/drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c
> > @@ -1462,6 +1462,7 @@ struct resource_pool *dce110_create_resource_pool(
> >       if (construct(num_virtual_links, dc, pool, asic_id))
> >               return &pool->base;
> >
> > +     kfree(pool);
> >       BREAK_TO_DEBUGGER();
> >       return NULL;
> >  }
> > diff --git a/drivers/gpu/drm/amd/display/dc/dce112/dce112_resource.c b/drivers/gpu/drm/amd/display/dc/dce112/dce112_resource.c
> > index 3ac4c7e73050..3199d493d13b 100644
> > --- a/drivers/gpu/drm/amd/display/dc/dce112/dce112_resource.c
> > +++ b/drivers/gpu/drm/amd/display/dc/dce112/dce112_resource.c
> > @@ -1338,6 +1338,7 @@ struct resource_pool *dce112_create_resource_pool(
> >       if (construct(num_virtual_links, dc, pool))
> >               return &pool->base;
> >
> > +     kfree(pool);
> >       BREAK_TO_DEBUGGER();
> >       return NULL;
> >  }
> > diff --git a/drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c b/drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c
> > index 7d08154e9662..bb497f43f6eb 100644
> > --- a/drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c
> > +++ b/drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c
> > @@ -1203,6 +1203,7 @@ struct resource_pool *dce120_create_resource_pool(
> >       if (construct(num_virtual_links, dc, pool))
> >               return &pool->base;
> >
> > +     kfree(pool);
> >       BREAK_TO_DEBUGGER();
> >       return NULL;
> >  }
> > diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c
> > index 5a89e462e7cc..59305e411a66 100644
> > --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c
> > +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c
> > @@ -1570,6 +1570,7 @@ struct resource_pool *dcn10_create_resource_pool(
> >       if (construct(init_data->num_virtual_links, dc, pool))
> >               return &pool->base;
> >
> > +     kfree(pool);
> >       BREAK_TO_DEBUGGER();
> >       return NULL;
> >  }
> >
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

end of thread, other threads:[~2019-09-25 16:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-25  4:23 [PATCH] drm/amd/display: prevent memory leak Navid Emamdoost
2019-09-25 13:54 ` Harry Wentland
2019-09-25 16:04   ` Alex Deucher

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).