public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] tools/vm: Fix possible resource leak in page_owner_sort.c
@ 2017-02-20 10:58 Saurabh Badhwar
  0 siblings, 0 replies; only message in thread
From: Saurabh Badhwar @ 2017-02-20 10:58 UTC (permalink / raw)
  To: linux-kernel; +Cc: kernel-janitors

The patch addresses explicit closing of file pointers on exit
and redirects the errors to the stderr
Signed-off-by: Saurabh Badhwar <sbsaurabhbadhwar9@gmail.com>
---
 tools/vm/page_owner_sort.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/vm/page_owner_sort.c b/tools/vm/page_owner_sort.c
index 8346261..b3c3efa 100644
--- a/tools/vm/page_owner_sort.c
+++ b/tools/vm/page_owner_sort.c
@@ -109,7 +109,7 @@ int main(int argc, char **argv)
 	list = malloc(max_size * sizeof(*list));
 	buf = malloc(BUF_SIZE);
 	if (!list || !buf) {
-		printf("Out of memory\n");
+		perror("Unable to allocate memory: ");
 		fclose(fin);
 		fclose(fout);
 		exit(1);
@@ -145,8 +145,8 @@ int main(int argc, char **argv)
 	qsort(list2, count, sizeof(list[0]), compare_num);
 
 	for (i = 0; i < count; i++)
-		fprintf(fout, "%d times:\n%s\n", list2[i].num, list2[i].txt);
-		
+		fprintf(fout, "%d times:\n%s\n", list2[i].num, list2[i].txt);	
+	
 	fclose(fout);
 	return 0;
 }
-- 
2.9.3


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2017-02-20 10:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-20 10:58 [PATCH v2] tools/vm: Fix possible resource leak in page_owner_sort.c Saurabh Badhwar

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