33
33
#include <bootm.h>
34
34
#include <image.h>
35
35
36
- #ifndef CONFIG_SYS_BOOTM_LEN
37
- /* use 8MByte as default max gunzip size */
38
- #define CONFIG_SYS_BOOTM_LEN 0x800000
39
- #endif
40
-
41
36
#define MAX_CMDLINE_SIZE SZ_4K
42
37
43
38
#define IH_INITRD_ARCH IH_ARCH_DEFAULT
@@ -369,18 +364,20 @@ static int bootm_find_other(struct cmd_tbl *cmdtp, int flag, int argc,
369
364
*
370
365
* @comp_type: Compression type being used (IH_COMP_...)
371
366
* @uncomp_size: Number of bytes uncompressed
367
+ * @buf_size: Number of bytes the decompresion buffer was
372
368
* @ret: errno error code received from compression library
373
369
* Return: Appropriate BOOTM_ERR_ error code
374
370
*/
375
- static int handle_decomp_error (int comp_type , size_t uncomp_size , int ret )
371
+ static int handle_decomp_error (int comp_type , size_t uncomp_size ,
372
+ size_t buf_size , int ret )
376
373
{
377
374
const char * name = genimg_get_comp_name (comp_type );
378
375
379
376
/* ENOSYS means unimplemented compression type, don't reset. */
380
377
if (ret == - ENOSYS )
381
378
return BOOTM_ERR_UNIMPLEMENTED ;
382
379
383
- if (uncomp_size >= CONFIG_SYS_BOOTM_LEN )
380
+ if (uncomp_size >= buf_size )
384
381
printf ("Image too large: increase CONFIG_SYS_BOOTM_LEN\n" );
385
382
else
386
383
printf ("%s: uncompress error %d\n" , name , ret );
@@ -420,7 +417,8 @@ static int bootm_load_os(bootm_headers_t *images, int boot_progress)
420
417
load_buf , image_buf , image_len ,
421
418
CONFIG_SYS_BOOTM_LEN , & load_end );
422
419
if (err ) {
423
- err = handle_decomp_error (os .comp , load_end - load , err );
420
+ err = handle_decomp_error (os .comp , load_end - load ,
421
+ CONFIG_SYS_BOOTM_LEN , err );
424
422
bootstage_error (BOOTSTAGE_ID_DECOMP_IMAGE );
425
423
return err ;
426
424
}
@@ -1006,7 +1004,7 @@ static int bootm_host_load_image(const void *fit, int req_image_type,
1006
1004
ulong data , len ;
1007
1005
bootm_headers_t images ;
1008
1006
int noffset ;
1009
- ulong load_end ;
1007
+ ulong load_end , buf_size ;
1010
1008
uint8_t image_type ;
1011
1009
uint8_t imape_comp ;
1012
1010
void * load_buf ;
@@ -1032,14 +1030,14 @@ static int bootm_host_load_image(const void *fit, int req_image_type,
1032
1030
}
1033
1031
1034
1032
/* Allow the image to expand by a factor of 4, should be safe */
1035
- load_buf = malloc ((1 << 20 ) + len * 4 );
1033
+ buf_size = (1 << 20 ) + len * 4 ;
1034
+ load_buf = malloc (buf_size );
1036
1035
ret = image_decomp (imape_comp , 0 , data , image_type , load_buf ,
1037
- (void * )data , len , CONFIG_SYS_BOOTM_LEN ,
1038
- & load_end );
1036
+ (void * )data , len , buf_size , & load_end );
1039
1037
free (load_buf );
1040
1038
1041
1039
if (ret ) {
1042
- ret = handle_decomp_error (imape_comp , load_end - 0 , ret );
1040
+ ret = handle_decomp_error (imape_comp , load_end - 0 , buf_size , ret );
1043
1041
if (ret != BOOTM_ERR_UNIMPLEMENTED )
1044
1042
return ret ;
1045
1043
}
0 commit comments