btrfs-progs: cleanup possible silent failure in btrfs-image
authorGui Hecheng <guihc.fnst@cn.fujitsu.com>
Thu, 26 Jun 2014 02:53:04 +0000 (10:53 +0800)
committerDavid Sterba <dsterba@suse.cz>
Fri, 22 Aug 2014 12:43:11 +0000 (14:43 +0200)
If the malloc above fails, the btrfs-image will exit directly
without any error messages.
Now just return the ENOMEM errno and let the caller prompt the
error message.

Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
btrfs-image.c

index 1a460ba..b8e8c4d 100644 (file)
@@ -2421,7 +2421,8 @@ static int update_disk_super_on_device(struct btrfs_fs_info *info,
        buf = malloc(BTRFS_SUPER_INFO_SIZE);
        if (!buf) {
                ret = -ENOMEM;
-               exit(1);
+               close(fp);
+               return ret;
        }
 
        memcpy(buf, info->super_copy, BTRFS_SUPER_INFO_SIZE);