Fix endless loop when trying to add a too large file to CBFS,
and report the correct error code, and a hopefully helpful
error message.


Signed-off-by: Patrick Georgi <patrick.georgi@coresystems.de>
Acked-by: Stefan Reinauer <stepan@coresystems.de>


git-svn-id: svn://svn.coreboot.org/coreboot/trunk@4692 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
diff --git a/util/cbfstool/cbfstool.c b/util/cbfstool/cbfstool.c
index 7fa7a85..bf8b381 100644
--- a/util/cbfstool/cbfstool.c
+++ b/util/cbfstool/cbfstool.c
@@ -80,7 +80,8 @@
 	}
 	cbfsfile =
 	    create_cbfs_file(cbfsname, filedata, &filesize, type, &base);
-	add_file_to_cbfs(cbfsfile, filesize, base);
+	if (add_file_to_cbfs(cbfsfile, filesize, base))
+		return 1;
 	writerom(romname, rom, romsize);
 	return 0;
 }
@@ -127,7 +128,8 @@
 	cbfsfile =
 	    create_cbfs_file(cbfsname, payload, &filesize,
 			     CBFS_COMPONENT_PAYLOAD, &base);
-	add_file_to_cbfs(cbfsfile, filesize, base);
+	if (add_file_to_cbfs(cbfsfile, filesize, base))
+		return 1;
 	writerom(romname, rom, romsize);
 	return 0;
 }
@@ -175,7 +177,8 @@
 	    create_cbfs_file(cbfsname, stage, &filesize,
 			     CBFS_COMPONENT_STAGE, &base);
 
-	add_file_to_cbfs(cbfsfile, filesize, base);
+	if (add_file_to_cbfs(cbfsfile, filesize, base))
+		return 1;
 	writerom(romname, rom, romsize);
 	return 0;
 }