summaryrefslogtreecommitdiff
path: root/btrfs-fragments.c
diff options
context:
space:
mode:
authorWang Shilong <wangsl.fnst@cn.fujitsu.com>2013-07-15 19:36:50 +0800
committerDavid Sterba <dsterba@suse.cz>2013-08-09 14:32:36 +0200
commitc125b7cf43aac815782ded0a0f36060e81c79726 (patch)
tree6d954a3f9e39f834bc96643bf5c574bdc9cea00e /btrfs-fragments.c
parentc118c21b3e855c37c01db4be5746055629b70a19 (diff)
Btrfs-progs: fix closing of opendir()
valgrind complains open_file_or_dir() causes a memory leak.That is because if we open a directoy by opendir(), and then we should call closedir() to free memory. Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Diffstat (limited to 'btrfs-fragments.c')
-rw-r--r--btrfs-fragments.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/btrfs-fragments.c b/btrfs-fragments.c
index 7ec77e78..4dd94700 100644
--- a/btrfs-fragments.c
+++ b/btrfs-fragments.c
@@ -403,6 +403,7 @@ int main(int argc, char **argv)
int ret;
u64 flags = 0;
char *dir = "html";
+ DIR *dirstream = NULL;
while (1) {
int c = getopt(argc, argv, "cmso:h");
@@ -437,7 +438,7 @@ int main(int argc, char **argv)
exit(1);
}
- fd = open_file_or_dir(path);
+ fd = open_file_or_dir(path, &dirstream);
if (fd < 0) {
fprintf(stderr, "ERROR: can't access '%s'\n", path);
exit(1);
@@ -447,6 +448,7 @@ int main(int argc, char **argv)
flags = BTRFS_BLOCK_GROUP_DATA | BTRFS_BLOCK_GROUP_METADATA;
ret = list_fragments(fd, flags, dir);
+ close_file_or_dir(fd, dirstream);
if (ret)
exit(1);