diff mbox

[4/6] btrfs-progs: cleanup possible silent failure in btrfs-image

Message ID 1403751186-31559-4-git-send-email-guihc.fnst@cn.fujitsu.com (mailing list archive)
State Accepted
Headers show

Commit Message

Gui Hecheng June 26, 2014, 2:53 a.m. UTC
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>
---
 btrfs-image.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/btrfs-image.c b/btrfs-image.c
index 2d482c3..e0aabfd 100644
--- a/btrfs-image.c
+++ b/btrfs-image.c
@@ -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);