linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/page_owner: Fix memory leak
@ 2015-01-16 12:11 Valentin Ilie
  2015-01-16 15:03 ` Paul Bolle
  0 siblings, 1 reply; 4+ messages in thread
From: Valentin Ilie @ 2015-01-16 12:11 UTC (permalink / raw)
  To: iamjoonsoo.kim, akpm, linux-kernel; +Cc: Valentin Ilie

Call kfree on list2 after using it.

Signed-off-by: Valentin Ilie <valentin.ilie@gmail.com>
---
 tools/vm/page_owner_sort.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/vm/page_owner_sort.c b/tools/vm/page_owner_sort.c
index 77147b4..92292d5 100644
--- a/tools/vm/page_owner_sort.c
+++ b/tools/vm/page_owner_sort.c
@@ -139,6 +139,8 @@ int main(int argc, char **argv)
 
 	for (i = 0; i < count; i++)
 		fprintf(fout, "%d times:\n%s\n", list2[i].num, list2[i].txt);
+	
+	kfree(list2);
 
 	return 0;
 }
-- 
2.1.0


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

* Re: [PATCH] mm/page_owner: Fix memory leak
  2015-01-16 12:11 [PATCH] mm/page_owner: Fix memory leak Valentin Ilie
@ 2015-01-16 15:03 ` Paul Bolle
  2015-01-16 15:30   ` Paul Bolle
  0 siblings, 1 reply; 4+ messages in thread
From: Paul Bolle @ 2015-01-16 15:03 UTC (permalink / raw)
  To: Valentin Ilie; +Cc: iamjoonsoo.kim, akpm, linux-kernel

On Fri, 2015-01-16 at 14:11 +0200, Valentin Ilie wrote:
> Call kfree on list2 after using it.
> 
> Signed-off-by: Valentin Ilie <valentin.ilie@gmail.com>
> ---
>  tools/vm/page_owner_sort.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/tools/vm/page_owner_sort.c b/tools/vm/page_owner_sort.c
> index 77147b4..92292d5 100644
> --- a/tools/vm/page_owner_sort.c
> +++ b/tools/vm/page_owner_sort.c
> @@ -139,6 +139,8 @@ int main(int argc, char **argv)
>  
>  	for (i = 0; i < count; i++)
>  		fprintf(fout, "%d times:\n%s\n", list2[i].num, list2[i].txt);
> +	

Checkpatch would have caught the tab you added here.

> +	kfree(list2);

You didn't even compile this, did you?
 
>  	return 0;
>  }

Thanks,


Paul Bolle


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

* Re: [PATCH] mm/page_owner: Fix memory leak
  2015-01-16 15:03 ` Paul Bolle
@ 2015-01-16 15:30   ` Paul Bolle
  2015-01-16 15:37     ` Valentin Ilie
  0 siblings, 1 reply; 4+ messages in thread
From: Paul Bolle @ 2015-01-16 15:30 UTC (permalink / raw)
  To: Valentin Ilie; +Cc: iamjoonsoo.kim, akpm, linux-kernel

(I dislike it when people set a trap for me, so on second thought I tell
you what I should have added right away.) 

On Fri, 2015-01-16 at 16:03 +0100, Paul Bolle wrote:
> On Fri, 2015-01-16 at 14:11 +0200, Valentin Ilie wrote:
> > Call kfree on list2 after using it.
> > 
> > Signed-off-by: Valentin Ilie <valentin.ilie@gmail.com>
> > ---
> >  tools/vm/page_owner_sort.c | 2 ++
> >  1 file changed, 2 insertions(+)
> > 
> > diff --git a/tools/vm/page_owner_sort.c b/tools/vm/page_owner_sort.c
> > index 77147b4..92292d5 100644
> > --- a/tools/vm/page_owner_sort.c
> > +++ b/tools/vm/page_owner_sort.c
> > @@ -139,6 +139,8 @@ int main(int argc, char **argv)
> >  
> >  	for (i = 0; i < count; i++)
> >  		fprintf(fout, "%d times:\n%s\n", list2[i].num, list2[i].txt);
> > +	
> 
> Checkpatch would have caught the tab you added here.
> 
> > +	kfree(list2);
> 
> You didn't even compile this, did you?
>  
> >  	return 0;
> >  }

Before you resend: what happens to the resources of a userspace program
when its main() returns?


Paul Bolle


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

* Re: [PATCH] mm/page_owner: Fix memory leak
  2015-01-16 15:30   ` Paul Bolle
@ 2015-01-16 15:37     ` Valentin Ilie
  0 siblings, 0 replies; 4+ messages in thread
From: Valentin Ilie @ 2015-01-16 15:37 UTC (permalink / raw)
  To: Paul Bolle; +Cc: iamjoonsoo.kim, akpm, linux-kernel

On 16 January 2015 at 17:30, Paul Bolle <pebolle@tiscali.nl> wrote:
> Before you resend: what happens to the resources of a userspace program
> when its main() returns?

On top of that, I should have used free, not kfree. I will resend v2 ..

Sorry for the mess

-- 
Valentin

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

end of thread, other threads:[~2015-01-16 15:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-16 12:11 [PATCH] mm/page_owner: Fix memory leak Valentin Ilie
2015-01-16 15:03 ` Paul Bolle
2015-01-16 15:30   ` Paul Bolle
2015-01-16 15:37     ` Valentin Ilie

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