Skip to contentSkip to conversation

mm/page_owner: Fix memory leak

PATCH In review Valentin Ilie 2 participants 4 messages Jan 16, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm/page_owner: Fix memory leak

Call kfree on list2 after using it.

---
 tools/vm/page_owner_sort.c | 2 ++
 1 file changed, 2 insertions(+)
tools/vm/page_owner_sort.c +2 -0
index 77147b4..92292d5 100644
@@ -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;
 }
Signature · 1 line
2.1.0
#1 lore raw
Quoted 12 lines · Valentin Ilie

Call kfree on list2 after using it.

---
 tools/vm/page_owner_sort.c | 2 ++
 1 file changed, 2 insertions(+)
tools/vm/page_owner_sort.c +0 -0
index 77147b4..92292d5 100644

tools/vm/page_owner_sort.c int main(int argc, char **argv) · line 142

Quoted 4 lines
tools/vm/page_owner_sort.c +1 -0
@@ -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.

tools/vm/page_owner_sort.c int main(int argc, char **argv) · line 143

Quoted 1 line
tools/vm/page_owner_sort.c +1 -0
+	kfree(list2);

You didn't even compile this, did you?

tools/vm/page_owner_sort.c int main(int argc, char **argv) · line 146

Quoted 2 lines
tools/vm/page_owner_sort.c +0 -0
 	return 0;
 }

Thanks,

Paul Bolle

#2 lore raw

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

Quoted 20 lines · Paul Bolle
Quoted 12 lines · Valentin Ilie

Call kfree on list2 after using it.

---
 tools/vm/page_owner_sort.c | 2 ++
 1 file changed, 2 insertions(+)
tools/vm/page_owner_sort.c +0 -0
index 77147b4..92292d5 100644

tools/vm/page_owner_sort.c int main(int argc, char **argv) · line 142

Quoted 4 lines
tools/vm/page_owner_sort.c +1 -0
@@ -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.

Quoted 6 lines

tools/vm/page_owner_sort.c int main(int argc, char **argv) · line 143

Quoted 1 line
tools/vm/page_owner_sort.c +1 -0
+	kfree(list2);

You didn't even compile this, did you?

Quoted 2 lines
tools/vm/page_owner_sort.c +0 -0
 	return 0;
 }

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

Paul Bolle

#3 lore raw
Quoted 2 lines · Paul Bolle

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

Signature · 1 line
Valentin