public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
From: Saurabh Badhwar <sbsaurabhbadhwar9@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: kernel-janitors@vger.kernel.org
Subject: [PATCH v2] tools/vm: Fix possible resource leak in page_owner_sort.c
Date: Mon, 20 Feb 2017 10:58:36 +0000	[thread overview]
Message-ID: <20170220104636.GA4607@localhost.localdomain> (raw)

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


                 reply	other threads:[~2017-02-20 10:58 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170220104636.GA4607@localhost.localdomain \
    --to=sbsaurabhbadhwar9@gmail.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox