public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nouveau: Do not leak in nv20_graph_create
@ 2011-07-03 10:25 Jesper Juhl
  2011-07-03 10:51 ` Paul Menzel
  0 siblings, 1 reply; 6+ messages in thread
From: Jesper Juhl @ 2011-07-03 10:25 UTC (permalink / raw)
  To: linux-kernel; +Cc: dri-devel, Ben Skeggs, David Airlie, Francisco Jerez

If we return due to an unknown chipset in 
drivers/gpu/drm/nouveau/nv20_graph.c:nv20_graph_create() we'll leak the 
memory allocated to 'pgraph'.

This patch should fix the leak and it also disambiguates the "PGRAPH:
unknown chipset\n" error message - it's nice to be able to tell which
branch created the error which is impossible if the error messages are
100% identical.

Signed-off-by: Jesper Juhl <jj@chaosbits.net>
---
 drivers/gpu/drm/nouveau/nv20_graph.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

  Don't have the hardware, so compile tested only.

diff --git a/drivers/gpu/drm/nouveau/nv20_graph.c b/drivers/gpu/drm/nouveau/nv20_graph.c
index affc7d7..059ad65 100644
--- a/drivers/gpu/drm/nouveau/nv20_graph.c
+++ b/drivers/gpu/drm/nouveau/nv20_graph.c
@@ -752,6 +752,7 @@ nv20_graph_create(struct drm_device *dev)
 			pgraph->grctx_user = 0x0000;
 			break;
 		default:
+			kfree(pgraph);
 			NV_ERROR(dev, "PGRAPH: unknown chipset\n");
 			return 0;
 		}
@@ -773,7 +774,8 @@ nv20_graph_create(struct drm_device *dev)
 			pgraph->grctx_size = NV35_36_GRCTX_SIZE;
 			break;
 		default:
-			NV_ERROR(dev, "PGRAPH: unknown chipset\n");
+			kfree(pgraph);
+			NV_ERROR(dev, "PGRAPH: unknown chipset.\n");
 			return 0;
 		}
 	}
-- 
1.7.6


-- 
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] 6+ messages in thread

* Re: [PATCH] nouveau: Do not leak in nv20_graph_create
  2011-07-03 10:25 [PATCH] nouveau: Do not leak in nv20_graph_create Jesper Juhl
@ 2011-07-03 10:51 ` Paul Menzel
  2011-07-03 11:16   ` Jesper Juhl
  0 siblings, 1 reply; 6+ messages in thread
From: Paul Menzel @ 2011-07-03 10:51 UTC (permalink / raw)
  To: dri-devel; +Cc: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1548 bytes --]

Dear Jesper,


Am Sonntag, den 03.07.2011, 12:25 +0200 schrieb Jesper Juhl:
> If we return due to an unknown chipset in 
> drivers/gpu/drm/nouveau/nv20_graph.c:nv20_graph_create() we'll leak the 
> memory allocated to 'pgraph'.
> 
> This patch should fix the leak and it also disambiguates the "PGRAPH:
> unknown chipset\n" error message - it's nice to be able to tell which
> branch created the error which is impossible if the error messages are
> 100% identical.
> 
> Signed-off-by: Jesper Juhl <jj@chaosbits.net>
> ---
>  drivers/gpu/drm/nouveau/nv20_graph.c |    4 +++-
>  1 files changed, 3 insertions(+), 1 deletions(-)
> 
>   Don't have the hardware, so compile tested only.
> 
> diff --git a/drivers/gpu/drm/nouveau/nv20_graph.c b/drivers/gpu/drm/nouveau/nv20_graph.c
> index affc7d7..059ad65 100644
> --- a/drivers/gpu/drm/nouveau/nv20_graph.c
> +++ b/drivers/gpu/drm/nouveau/nv20_graph.c
> @@ -752,6 +752,7 @@ nv20_graph_create(struct drm_device *dev)
>  			pgraph->grctx_user = 0x0000;
>  			break;
>  		default:
> +			kfree(pgraph);
>  			NV_ERROR(dev, "PGRAPH: unknown chipset\n");
>  			return 0;
>  		}
> @@ -773,7 +774,8 @@ nv20_graph_create(struct drm_device *dev)
>  			pgraph->grctx_size = NV35_36_GRCTX_SIZE;
>  			break;
>  		default:
> -			NV_ERROR(dev, "PGRAPH: unknown chipset\n");
> +			kfree(pgraph);
> +			NV_ERROR(dev, "PGRAPH: unknown chipset.\n");

so the only disambiguation is the full stop at the end?

>  			return 0;
>  		}
>  	}
> -- 
> 1.7.6


Thanks,

Paul

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

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

* Re: [PATCH] nouveau: Do not leak in nv20_graph_create
  2011-07-03 10:51 ` Paul Menzel
@ 2011-07-03 11:16   ` Jesper Juhl
  2011-07-03 11:21     ` Jesper Juhl
  0 siblings, 1 reply; 6+ messages in thread
From: Jesper Juhl @ 2011-07-03 11:16 UTC (permalink / raw)
  To: Paul Menzel; +Cc: dri-devel, linux-kernel

On Sun, 3 Jul 2011, Paul Menzel wrote:

> Dear Jesper,
> 
> 
> Am Sonntag, den 03.07.2011, 12:25 +0200 schrieb Jesper Juhl:
> > If we return due to an unknown chipset in 
> > drivers/gpu/drm/nouveau/nv20_graph.c:nv20_graph_create() we'll leak the 
> > memory allocated to 'pgraph'.
> > 
> > This patch should fix the leak and it also disambiguates the "PGRAPH:
> > unknown chipset\n" error message - it's nice to be able to tell which
> > branch created the error which is impossible if the error messages are
> > 100% identical.
> > 
> > Signed-off-by: Jesper Juhl <jj@chaosbits.net>
> > ---
> >  drivers/gpu/drm/nouveau/nv20_graph.c |    4 +++-
> >  1 files changed, 3 insertions(+), 1 deletions(-)
> > 
> >   Don't have the hardware, so compile tested only.
> > 
> > diff --git a/drivers/gpu/drm/nouveau/nv20_graph.c b/drivers/gpu/drm/nouveau/nv20_graph.c
> > index affc7d7..059ad65 100644
> > --- a/drivers/gpu/drm/nouveau/nv20_graph.c
> > +++ b/drivers/gpu/drm/nouveau/nv20_graph.c
> > @@ -752,6 +752,7 @@ nv20_graph_create(struct drm_device *dev)
> >  			pgraph->grctx_user = 0x0000;
> >  			break;
> >  		default:
> > +			kfree(pgraph);
> >  			NV_ERROR(dev, "PGRAPH: unknown chipset\n");
> >  			return 0;
> >  		}
> > @@ -773,7 +774,8 @@ nv20_graph_create(struct drm_device *dev)
> >  			pgraph->grctx_size = NV35_36_GRCTX_SIZE;
> >  			break;
> >  		default:
> > -			NV_ERROR(dev, "PGRAPH: unknown chipset\n");
> > +			kfree(pgraph);
> > +			NV_ERROR(dev, "PGRAPH: unknown chipset.\n");
> 
> so the only disambiguation is the full stop at the end?
> 
Yeah. I guess I could have reworded the text, but I settled on just adding 
that "."...

-- 
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	[flat|nested] 6+ messages in thread

* Re: [PATCH] nouveau: Do not leak in nv20_graph_create
  2011-07-03 11:16   ` Jesper Juhl
@ 2011-07-03 11:21     ` Jesper Juhl
  2011-07-03 14:39       ` Marcin Slusarz
  0 siblings, 1 reply; 6+ messages in thread
From: Jesper Juhl @ 2011-07-03 11:21 UTC (permalink / raw)
  To: Paul Menzel; +Cc: dri-devel, linux-kernel

On Sun, 3 Jul 2011, Jesper Juhl wrote:

> On Sun, 3 Jul 2011, Paul Menzel wrote:
> 
> > Dear Jesper,
> > 
> > 
> > Am Sonntag, den 03.07.2011, 12:25 +0200 schrieb Jesper Juhl:
> > > If we return due to an unknown chipset in 
> > > drivers/gpu/drm/nouveau/nv20_graph.c:nv20_graph_create() we'll leak the 
> > > memory allocated to 'pgraph'.
> > > 
> > > This patch should fix the leak and it also disambiguates the "PGRAPH:
> > > unknown chipset\n" error message - it's nice to be able to tell which
> > > branch created the error which is impossible if the error messages are
> > > 100% identical.
> > > 
> > > Signed-off-by: Jesper Juhl <jj@chaosbits.net>
> > > ---
> > >  drivers/gpu/drm/nouveau/nv20_graph.c |    4 +++-
> > >  1 files changed, 3 insertions(+), 1 deletions(-)
> > > 
> > >   Don't have the hardware, so compile tested only.
> > > 
> > > diff --git a/drivers/gpu/drm/nouveau/nv20_graph.c b/drivers/gpu/drm/nouveau/nv20_graph.c
> > > index affc7d7..059ad65 100644
> > > --- a/drivers/gpu/drm/nouveau/nv20_graph.c
> > > +++ b/drivers/gpu/drm/nouveau/nv20_graph.c
> > > @@ -752,6 +752,7 @@ nv20_graph_create(struct drm_device *dev)
> > >  			pgraph->grctx_user = 0x0000;
> > >  			break;
> > >  		default:
> > > +			kfree(pgraph);
> > >  			NV_ERROR(dev, "PGRAPH: unknown chipset\n");
> > >  			return 0;
> > >  		}
> > > @@ -773,7 +774,8 @@ nv20_graph_create(struct drm_device *dev)
> > >  			pgraph->grctx_size = NV35_36_GRCTX_SIZE;
> > >  			break;
> > >  		default:
> > > -			NV_ERROR(dev, "PGRAPH: unknown chipset\n");
> > > +			kfree(pgraph);
> > > +			NV_ERROR(dev, "PGRAPH: unknown chipset.\n");
> > 
> > so the only disambiguation is the full stop at the end?
> > 
> Yeah. I guess I could have reworded the text, but I settled on just adding 
> that "."...
> 
I guess this is better : 


From: Jesper Juhl <jj@chaosbits.net>
Subject: [PATCH] nouveau: Do not leak in nv20_graph_create

If we return due to an unknown chipset in drivers/gpu/drm/nouveau/nv20_graph.c:nv20_graph_create() we'll leak the memory allocated to 'pgraph'.

This patch should fix the leak and it also disambiguates the "PGRAPH:
unknown chipset\n" error message - it's nice to be able to tell which
branch created the error which is impossible if the error messages are
100% identical.

Signed-off-by: Jesper Juhl <jj@chaosbits.net>
---
 drivers/gpu/drm/nouveau/nv20_graph.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nv20_graph.c b/drivers/gpu/drm/nouveau/nv20_graph.c
index affc7d7..53cbe84 100644
--- a/drivers/gpu/drm/nouveau/nv20_graph.c
+++ b/drivers/gpu/drm/nouveau/nv20_graph.c
@@ -752,6 +752,7 @@ nv20_graph_create(struct drm_device *dev)
 			pgraph->grctx_user = 0x0000;
 			break;
 		default:
+			kfree(pgraph);
 			NV_ERROR(dev, "PGRAPH: unknown chipset\n");
 			return 0;
 		}
@@ -773,7 +774,8 @@ nv20_graph_create(struct drm_device *dev)
 			pgraph->grctx_size = NV35_36_GRCTX_SIZE;
 			break;
 		default:
-			NV_ERROR(dev, "PGRAPH: unknown chipset\n");
+			kfree(pgraph);
+			NV_ERROR(dev, "PGRAPH: chipset unknown.\n");
 			return 0;
 		}
 	}
-- 
1.7.6



-- 
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] 6+ messages in thread

* Re: [PATCH] nouveau: Do not leak in nv20_graph_create
  2011-07-03 11:21     ` Jesper Juhl
@ 2011-07-03 14:39       ` Marcin Slusarz
  2011-07-03 23:46         ` Ben Skeggs
  0 siblings, 1 reply; 6+ messages in thread
From: Marcin Slusarz @ 2011-07-03 14:39 UTC (permalink / raw)
  To: Jesper Juhl; +Cc: Paul Menzel, linux-kernel, dri-devel

On Sun, Jul 03, 2011 at 01:21:55PM +0200, Jesper Juhl wrote:
> From: Jesper Juhl <jj@chaosbits.net>
> Subject: [PATCH] nouveau: Do not leak in nv20_graph_create
> 
> If we return due to an unknown chipset in drivers/gpu/drm/nouveau/nv20_graph.c:nv20_graph_create() we'll leak the memory allocated to 'pgraph'.
> 
> This patch should fix the leak and it also disambiguates the "PGRAPH:
> unknown chipset\n" error message - it's nice to be able to tell which
> branch created the error which is impossible if the error messages are
> 100% identical.

There's no need to change these strings. Nouveau prints chipset id earlier.
For patch with only kfrees:
Reviewed-by: Marcin Slusarz <marcin.slusarz@gmail.com>

> Signed-off-by: Jesper Juhl <jj@chaosbits.net>
> ---
>  drivers/gpu/drm/nouveau/nv20_graph.c |    4 +++-
>  1 files changed, 3 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/gpu/drm/nouveau/nv20_graph.c b/drivers/gpu/drm/nouveau/nv20_graph.c
> index affc7d7..53cbe84 100644
> --- a/drivers/gpu/drm/nouveau/nv20_graph.c
> +++ b/drivers/gpu/drm/nouveau/nv20_graph.c
> @@ -752,6 +752,7 @@ nv20_graph_create(struct drm_device *dev)
>  			pgraph->grctx_user = 0x0000;
>  			break;
>  		default:
> +			kfree(pgraph);
>  			NV_ERROR(dev, "PGRAPH: unknown chipset\n");
>  			return 0;
>  		}
> @@ -773,7 +774,8 @@ nv20_graph_create(struct drm_device *dev)
>  			pgraph->grctx_size = NV35_36_GRCTX_SIZE;
>  			break;
>  		default:
> -			NV_ERROR(dev, "PGRAPH: unknown chipset\n");
> +			kfree(pgraph);
> +			NV_ERROR(dev, "PGRAPH: chipset unknown.\n");
>  			return 0;
>  		}
>  	}
> -- 

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

* Re: [PATCH] nouveau: Do not leak in nv20_graph_create
  2011-07-03 14:39       ` Marcin Slusarz
@ 2011-07-03 23:46         ` Ben Skeggs
  0 siblings, 0 replies; 6+ messages in thread
From: Ben Skeggs @ 2011-07-03 23:46 UTC (permalink / raw)
  To: Marcin Slusarz; +Cc: Jesper Juhl, Paul Menzel, dri-devel, linux-kernel

On Mon, Jul 4, 2011 at 12:39 AM, Marcin Slusarz
<marcin.slusarz@gmail.com> wrote:
> On Sun, Jul 03, 2011 at 01:21:55PM +0200, Jesper Juhl wrote:
>> From: Jesper Juhl <jj@chaosbits.net>
>> Subject: [PATCH] nouveau: Do not leak in nv20_graph_create
>>
>> If we return due to an unknown chipset in drivers/gpu/drm/nouveau/nv20_graph.c:nv20_graph_create() we'll leak the memory allocated to 'pgraph'.
>>
>> This patch should fix the leak and it also disambiguates the "PGRAPH:
>> unknown chipset\n" error message - it's nice to be able to tell which
>> branch created the error which is impossible if the error messages are
>> 100% identical.
>
> There's no need to change these strings. Nouveau prints chipset id earlier.
> For patch with only kfrees:
> Reviewed-by: Marcin Slusarz <marcin.slusarz@gmail.com>
Agreed, I've pulled just the kfree()s into my tree.  They'll hit
nouveau git either today or tomorrow.

Thank you!
Ben.

>
>> Signed-off-by: Jesper Juhl <jj@chaosbits.net>
>> ---
>>  drivers/gpu/drm/nouveau/nv20_graph.c |    4 +++-
>>  1 files changed, 3 insertions(+), 1 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/nouveau/nv20_graph.c b/drivers/gpu/drm/nouveau/nv20_graph.c
>> index affc7d7..53cbe84 100644
>> --- a/drivers/gpu/drm/nouveau/nv20_graph.c
>> +++ b/drivers/gpu/drm/nouveau/nv20_graph.c
>> @@ -752,6 +752,7 @@ nv20_graph_create(struct drm_device *dev)
>>                       pgraph->grctx_user = 0x0000;
>>                       break;
>>               default:
>> +                     kfree(pgraph);
>>                       NV_ERROR(dev, "PGRAPH: unknown chipset\n");
>>                       return 0;
>>               }
>> @@ -773,7 +774,8 @@ nv20_graph_create(struct drm_device *dev)
>>                       pgraph->grctx_size = NV35_36_GRCTX_SIZE;
>>                       break;
>>               default:
>> -                     NV_ERROR(dev, "PGRAPH: unknown chipset\n");
>> +                     kfree(pgraph);
>> +                     NV_ERROR(dev, "PGRAPH: chipset unknown.\n");
>>                       return 0;
>>               }
>>       }
>> --
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
>

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

end of thread, other threads:[~2011-07-03 23:46 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-03 10:25 [PATCH] nouveau: Do not leak in nv20_graph_create Jesper Juhl
2011-07-03 10:51 ` Paul Menzel
2011-07-03 11:16   ` Jesper Juhl
2011-07-03 11:21     ` Jesper Juhl
2011-07-03 14:39       ` Marcin Slusarz
2011-07-03 23:46         ` Ben Skeggs

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