summaryrefslogtreecommitdiff
path: root/cmds-inspect.c
diff options
context:
space:
mode:
authorZach Brown <zab@redhat.com>2013-01-24 10:53:49 -0800
committerZach Brown <zab@redhat.com>2013-02-05 16:09:41 -0800
commita70837ab1e33ceee70b5bc8c1d5969b897e57b72 (patch)
tree9ff8c6a157c1a17e9a55bfbde6ee69b95b63ca7d /cmds-inspect.c
parentdf13b84670264657da35146d0f3a10e0a5989503 (diff)
btrfs-progs: don't leak fds in logical resolve
Signed-off-by: Zach Brown <zab@redhat.com>
Diffstat (limited to 'cmds-inspect.c')
-rw-r--r--cmds-inspect.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/cmds-inspect.c b/cmds-inspect.c
index 4347c1a..e02b53a 100644
--- a/cmds-inspect.c
+++ b/cmds-inspect.c
@@ -212,8 +212,10 @@ static int cmd_logical_resolve(int argc, char **argv)
if (getpath) {
name = btrfs_list_path_for_root(fd, root);
- if (IS_ERR(name))
- return PTR_ERR(name);
+ if (IS_ERR(name)) {
+ ret = PTR_ERR(name);
+ goto out;
+ }
if (!name) {
path_ptr[-1] = '\0';
path_fd = fd;
@@ -231,6 +233,8 @@ static int cmd_logical_resolve(int argc, char **argv)
}
}
__ino_to_path_fd(inum, path_fd, verbose, full_path);
+ if (path_fd != fd)
+ close(path_fd);
} else {
printf("inode %llu offset %llu root %llu\n", inum,
offset, root);
@@ -238,6 +242,8 @@ static int cmd_logical_resolve(int argc, char **argv)
}
out:
+ if (fd >= 0)
+ close(fd);
free(inodes);
return ret;
}