diff mbox

Btrfs-progs: return with -ENOMEM if malloc fails

Message ID 20140315114613.GA8420@localhost.localdomain (mailing list archive)
State Accepted, archived
Headers show

Commit Message

Rakesh Pandit March 15, 2014, 11:46 a.m. UTC
Prevent segfault if memory allocation fails for sargs in get_df
(cmds-filesystem.c).

Signed-off-by: Rakesh Pandit <rakesh@tuxera.com>
---
 cmds-filesystem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox

Patch

diff --git a/cmds-filesystem.c b/cmds-filesystem.c
index c9e27fc..7eb6e9d 100644
--- a/cmds-filesystem.c
+++ b/cmds-filesystem.c
@@ -146,7 +146,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;