ARM: zImage: don't ignore error returned from decompress()
authorNicolas Pitre <nicolas.pitre@linaro.org>
Fri, 22 Apr 2011 01:59:49 +0000 (21:59 -0400)
committerNicolas Pitre <nico@fluxnic.net>
Sat, 7 May 2011 04:08:01 +0000 (00:08 -0400)
If decompress() returns an error without calling error(), we must
not attempt to boot the resulting kernel.

Signed-off-by: Nicolas Pitre <nicolas.pitre@linaro.org>
Tested-by: Shawn Guo <shawn.guo@linaro.org>
Tested-by: Tony Lindgren <tony@atomide.com>
arch/arm/boot/compressed/decompress.c
arch/arm/boot/compressed/misc.c

index 4c72a97bc3e1405318eaeeafaf130cf998049515..07be5a2f830236736b15022da52fa0362ff5c16f 100644 (file)
@@ -44,7 +44,7 @@ extern void error(char *);
 #include "../../../../lib/decompress_unlzma.c"
 #endif
 
-void do_decompress(u8 *input, int len, u8 *output, void (*error)(char *x))
+int do_decompress(u8 *input, int len, u8 *output, void (*error)(char *x))
 {
-       decompress(input, len, NULL, NULL, output, NULL, error);
+       return decompress(input, len, NULL, NULL, output, NULL, error);
 }
index 51b87b54a7ef7278076ddcfd8d0db638ffdee399..65871a7ba0d73acd4d2ae0eb7256fe5b2372566f 100644 (file)
@@ -177,7 +177,7 @@ asmlinkage void __div0(void)
        error("Attempting division by 0!");
 }
 
-extern void do_decompress(u8 *input, int len, u8 *output, void (*error)(char *x));
+extern int do_decompress(u8 *input, int len, u8 *output, void (*error)(char *x));
 
 
 void
@@ -185,6 +185,8 @@ decompress_kernel(unsigned long output_start, unsigned long free_mem_ptr_p,
                unsigned long free_mem_ptr_end_p,
                int arch_id)
 {
+       int ret;
+
        output_data             = (unsigned char *)output_start;
        free_mem_ptr            = free_mem_ptr_p;
        free_mem_end_ptr        = free_mem_ptr_end_p;
@@ -193,7 +195,10 @@ decompress_kernel(unsigned long output_start, unsigned long free_mem_ptr_p,
        arch_decomp_setup();
 
        putstr("Uncompressing Linux...");
-       do_decompress(input_data, input_data_end - input_data,
-                       output_data, error);
-       putstr(" done, booting the kernel.\n");
+       ret = do_decompress(input_data, input_data_end - input_data,
+                           output_data, error);
+       if (ret)
+               error("decompressor returned an error");
+       else
+               putstr(" done, booting the kernel.\n");
 }