Skip to contentSkip to conversation

Btrfs-progs: return with -ENOMEM if malloc fails

PATCH New Rakesh Pandit 1 participant 1 message Mar 15, 2014 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Btrfs-progs: return with -ENOMEM if malloc fails

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

---
 cmds-filesystem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
cmds-filesystem.c +1 -1
index c9e27fc..7eb6e9d 100644
@@ -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;
Signature · 1 line
1.8.5.3