Btrfs-progs: return with -ENOMEM if malloc fails
authorRakesh Pandit <rakesh@tuxera.com>
Sat, 15 Mar 2014 11:46:15 +0000 (13:46 +0200)
committerChris Mason <clm@fb.com>
Fri, 21 Mar 2014 16:51:31 +0000 (09:51 -0700)
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>
cmds-filesystem.c

index fbf2e10..bd9ba66 100644 (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;