diff options
author | Zhi Yong Wu <wuzhy@linux.vnet.ibm.com> | 2012-09-24 20:02:15 -0600 |
---|---|---|
committer | root <root@localhost.localdomain> | 2012-10-04 16:26:34 -0400 |
commit | 4a39f7d5d19c099050af7529965c29ca5167b7db (patch) | |
tree | 62c32823f00c04cf9e34d2e5ac584af869cdb0bd | |
parent | 32be2a1164b58b37af7c38e83bb2d30b1095e224 (diff) |
btrfs-progs: Close file descriptor on exit
Need to close fd on exit.
Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
-rw-r--r-- | cmds-filesystem.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/cmds-filesystem.c b/cmds-filesystem.c index b1457de7..e62c4fd6 100644 --- a/cmds-filesystem.c +++ b/cmds-filesystem.c @@ -77,18 +77,23 @@ static int cmd_df(int argc, char **argv) if (ret) { fprintf(stderr, "ERROR: couldn't get space info on '%s' - %s\n", path, strerror(e)); + close(fd); free(sargs); return ret; } - if (!sargs->total_spaces) + if (!sargs->total_spaces) { + close(fd); return 0; + } count = sargs->total_spaces; sargs = realloc(sargs, sizeof(struct btrfs_ioctl_space_args) + (count * sizeof(struct btrfs_ioctl_space_info))); - if (!sargs) + if (!sargs) { + close(fd); return -ENOMEM; + } sargs->space_slots = count; sargs->total_spaces = 0; @@ -148,6 +153,7 @@ static int cmd_df(int argc, char **argv) printf("%s: total=%s, used=%s\n", description, total_bytes, used_bytes); } + close(fd); free(sargs); return 0; |