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>
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;
return 12;
}
- sargs = malloc(sizeof(struct btrfs_ioctl_space_args));
+ sargs_orig = sargs = malloc(sizeof(struct btrfs_ioctl_space_args));
if (!sargs)
return -ENOMEM;
}
if (!sargs->total_spaces) {
close(fd);
+ free(sargs);
return 0;
}
(count * sizeof(struct btrfs_ioctl_space_info)));
if (!sargs) {
close(fd);
+ free(sargs_orig);
return -ENOMEM;
}