Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ARM: zImage: don't ignore error returned from decompress()

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>

authored by

Nicolas Pitre and committed by
Nicolas Pitre
ccc1c7c6 e40f1e9f

+11 -6
+2 -2
arch/arm/boot/compressed/decompress.c
··· 44 44 #include "../../../../lib/decompress_unlzma.c" 45 45 #endif 46 46 47 - void do_decompress(u8 *input, int len, u8 *output, void (*error)(char *x)) 47 + int do_decompress(u8 *input, int len, u8 *output, void (*error)(char *x)) 48 48 { 49 - decompress(input, len, NULL, NULL, output, NULL, error); 49 + return decompress(input, len, NULL, NULL, output, NULL, error); 50 50 }
+9 -4
arch/arm/boot/compressed/misc.c
··· 177 177 error("Attempting division by 0!"); 178 178 } 179 179 180 - extern void do_decompress(u8 *input, int len, u8 *output, void (*error)(char *x)); 180 + extern int do_decompress(u8 *input, int len, u8 *output, void (*error)(char *x)); 181 181 182 182 183 183 void ··· 185 185 unsigned long free_mem_ptr_end_p, 186 186 int arch_id) 187 187 { 188 + int ret; 189 + 188 190 output_data = (unsigned char *)output_start; 189 191 free_mem_ptr = free_mem_ptr_p; 190 192 free_mem_end_ptr = free_mem_ptr_end_p; ··· 195 193 arch_decomp_setup(); 196 194 197 195 putstr("Uncompressing Linux..."); 198 - do_decompress(input_data, input_data_end - input_data, 199 - output_data, error); 200 - putstr(" done, booting the kernel.\n"); 196 + ret = do_decompress(input_data, input_data_end - input_data, 197 + output_data, error); 198 + if (ret) 199 + error("decompressor returned an error"); 200 + else 201 + putstr(" done, booting the kernel.\n"); 201 202 }