btrfs-progs: don't leak fds in logical resolve
Signed-off-by: Zach Brown <zab@redhat.com>
This commit is contained in:
parent
df13b84670
commit
a70837ab1e
|
@ -212,8 +212,10 @@ static int cmd_logical_resolve(int argc, char **argv)
|
||||||
|
|
||||||
if (getpath) {
|
if (getpath) {
|
||||||
name = btrfs_list_path_for_root(fd, root);
|
name = btrfs_list_path_for_root(fd, root);
|
||||||
if (IS_ERR(name))
|
if (IS_ERR(name)) {
|
||||||
return PTR_ERR(name);
|
ret = PTR_ERR(name);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
if (!name) {
|
if (!name) {
|
||||||
path_ptr[-1] = '\0';
|
path_ptr[-1] = '\0';
|
||||||
path_fd = fd;
|
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);
|
__ino_to_path_fd(inum, path_fd, verbose, full_path);
|
||||||
|
if (path_fd != fd)
|
||||||
|
close(path_fd);
|
||||||
} else {
|
} else {
|
||||||
printf("inode %llu offset %llu root %llu\n", inum,
|
printf("inode %llu offset %llu root %llu\n", inum,
|
||||||
offset, root);
|
offset, root);
|
||||||
|
@ -238,6 +242,8 @@ static int cmd_logical_resolve(int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
if (fd >= 0)
|
||||||
|
close(fd);
|
||||||
free(inodes);
|
free(inodes);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue