linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: linux-btrfs@vger.kernel.org
Cc: arjan@linux.intel.com, David Sterba <dsterba@suse.cz>
Subject: [PATCH] btrfs-progs: call endmntent in btrfs_scan_kernel
Date: Wed, 27 Nov 2013 18:18:38 +0100	[thread overview]
Message-ID: <1385572718-3133-1-git-send-email-dsterba@suse.cz> (raw)

btrfs_scan_kernel() does a getmntent() but never releases the
filedescriptor it gets back from that.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=64711

Reported-by: Arjan van de Ven <arjan@linux.intel.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
---
 cmds-filesystem.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/cmds-filesystem.c b/cmds-filesystem.c
index 8296fa1ebb44..8e4754f84647 100644
--- a/cmds-filesystem.c
+++ b/cmds-filesystem.c
@@ -449,11 +449,12 @@ static int btrfs_scan_kernel(void *search)
 		ret = get_fs_info(mnt->mnt_dir, &fs_info_arg,
 				&dev_info_arg);
 		if (ret)
-			return ret;
+			goto out;
 
 		if (get_label_mounted(mnt->mnt_dir, label)) {
 			kfree(dev_info_arg);
-			return 1;
+			ret = 1;
+			goto out;
 		}
 		if (search && !match_search_item_kernel(fs_info_arg.fsid,
 					mnt->mnt_dir, label, search)) {
@@ -472,11 +473,14 @@ static int btrfs_scan_kernel(void *search)
 			close(fd);
 		kfree(dev_info_arg);
 		if (search)
-			return 0;
+			ret = 0;
 	}
 	if (search)
-		return 1;
-	return 0;
+		ret = 1;
+
+out:
+	endmntent(f);
+	return ret;
 }
 
 static const char * const cmd_show_usage[] = {
-- 
1.8.4.3


                 reply	other threads:[~2013-11-27 17:18 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=1385572718-3133-1-git-send-email-dsterba@suse.cz \
    --to=dsterba@suse.cz \
    --cc=arjan@linux.intel.com \
    --cc=linux-btrfs@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;
as well as URLs for NNTP newsgroup(s).