diff options
author | Zhi Yong Wu <wuzhy@linux.vnet.ibm.com> | 2012-09-24 20:02:16 -0600 |
---|---|---|
committer | root <root@localhost.localdomain> | 2012-10-04 16:26:34 -0400 |
commit | f38a139a965b03d45a1290be6280073c0a0ee8e1 (patch) | |
tree | 6e5198af53779a8e0d217c89dbb88ac9ce288797 /cmds-filesystem.c | |
parent | 4a39f7d5d19c099050af7529965c29ca5167b7db (diff) |
btrfs-progs: Fix up memory leakage
Some code pathes forget to free memory on exit.
Changelog from v1:
Fix the variable is used uncorrectly. [Ram Pai]
Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Diffstat (limited to 'cmds-filesystem.c')
-rw-r--r-- | cmds-filesystem.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/cmds-filesystem.c b/cmds-filesystem.c index e62c4fd6..9c43d351 100644 --- a/cmds-filesystem.c +++ b/cmds-filesystem.c @@ -47,7 +47,7 @@ static const char * const cmd_df_usage[] = { static int cmd_df(int argc, char **argv) { - struct btrfs_ioctl_space_args *sargs; + struct btrfs_ioctl_space_args *sargs, *sargs_orig; u64 count = 0, i; int ret; int fd; @@ -65,7 +65,7 @@ static int cmd_df(int argc, char **argv) return 12; } - sargs = malloc(sizeof(struct btrfs_ioctl_space_args)); + sargs_orig = sargs = malloc(sizeof(struct btrfs_ioctl_space_args)); if (!sargs) return -ENOMEM; @@ -83,6 +83,7 @@ static int cmd_df(int argc, char **argv) } if (!sargs->total_spaces) { close(fd); + free(sargs); return 0; } @@ -92,6 +93,7 @@ static int cmd_df(int argc, char **argv) (count * sizeof(struct btrfs_ioctl_space_info))); if (!sargs) { close(fd); + free(sargs_orig); return -ENOMEM; } |