Btrfs-progs: return with -ENOMEM if malloc fails

Prevent segfault if memory allocation fails for sargs in get_df
(cmds-filesystem.c).

Signed-off-by: Rakesh Pandit <rakesh@tuxera.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
This commit is contained in:
Rakesh Pandit 2014-03-15 13:46:15 +02:00 committed by Chris Mason
parent 5d48302236
commit 40af8f4ae7

View File

@ -188,7 +188,7 @@ static int get_df(int fd, struct btrfs_ioctl_space_args **sargs_ret)
sargs = malloc(sizeof(struct btrfs_ioctl_space_args) +
(count * sizeof(struct btrfs_ioctl_space_info)));
if (!sargs)
ret = -ENOMEM;
return -ENOMEM;
sargs->space_slots = count;
sargs->total_spaces = 0;