Piggy loader: Fix output buf size for LZMA decompr

commit 3be7654eaa6289e08bc2bd4d58d02f344d61ab73 fixed
lzmaBuffToBuffDecompress such that it behaves as intended by upstream
U-Boot: It now interprets the second argument *uncompressedSize as the
size of the output buffer. Previously, it just ignored this value and
potentially overran the output buffer. However, because this value did
not play a role, the piggy loader passed in some uninitialized value. If
this value turns out to be smaller than the size of the uncompressed
U-Boot image, the decompression will stop pre-maturely. To add to this
misery, the piggy loader would not check the return value of
lzmaBuffToBuffDecompress() but instead run some franken image which
could be the leftover of some previous image.

This change passes in the correct size of the output buffer, checks the
return value of lzmaBuffToBuffDecompress() and hangs if it failed.

Change-Id: I19858a4c253514db52c9bb6829c22bdcd4cebb04
diff --git a/board/ruby_mini/ruby_piggy.c b/board/ruby_mini/ruby_piggy.c
index bd93c63..c47b831 100644
--- a/board/ruby_mini/ruby_piggy.c
+++ b/board/ruby_mini/ruby_piggy.c
@@ -60,7 +60,7 @@
 	int __attribute__((unused)) rc;
 
 	unsigned long decompression_addr = RUBY_SRAM_BEGIN + TEXT_BASE_OFFSET_CHILD;
-	unsigned long uncompressed_size;
+	unsigned long uncompressed_size = RUBY_SRAM_SIZE - TEXT_BASE_OFFSET_CHILD;;
 	void (*start)(void) __attribute__((noreturn));
 
 	debug_setup();
@@ -73,6 +73,8 @@
 	/* decompress u-boot mini */
 	rc = lzmaBuffToBuffDecompress((void *) decompression_addr, &uncompressed_size,
 			payload, payload_len);
+	/* Hang if decompression failed. */
+	if (rc) for(;;) ;
 	DBGVAR(rc);
 
 	/* copy over early config bytes */