summaryrefslogtreecommitdiff
path: root/boot/bootm.c
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2022-06-26 02:29:46 +0300
committerTom Rini <trini@konsulko.com>2022-07-07 21:01:09 +0300
commitc45568cc4e51b7bbe2f3ce28d8f2566048aeebf3 (patch)
treebb66c9a10c18650315c7bf140ee85eab6d64ddc7 /boot/bootm.c
parent64a2a7b04b0a50e50a7cd36d7956d40c7a874478 (diff)
downloadu-boot-c45568cc4e51b7bbe2f3ce28d8f2566048aeebf3.tar.xz
Convert CONFIG_SYS_BOOTM_LEN to Kconfig
This converts the following to Kconfig: CONFIG_SYS_BOOTM_LEN As part of this, rework error handling in boot/bootm.c so that we pass the buffer size to handle_decomp_error as CONFIG_SYS_BOOTM_LEN will not be available to host tools but we do know the size that we passed to malloc(). Cc: Soeren Moch <smoch@web.de> Signed-off-by: Tom Rini <trini@konsulko.com>
Diffstat (limited to 'boot/bootm.c')
-rw-r--r--boot/bootm.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/boot/bootm.c b/boot/bootm.c
index dfa65f125e..86dbfbcfed 100644
--- a/boot/bootm.c
+++ b/boot/bootm.c
@@ -33,11 +33,6 @@
#include <bootm.h>
#include <image.h>
-#ifndef CONFIG_SYS_BOOTM_LEN
-/* use 8MByte as default max gunzip size */
-#define CONFIG_SYS_BOOTM_LEN 0x800000
-#endif
-
#define MAX_CMDLINE_SIZE SZ_4K
#define IH_INITRD_ARCH IH_ARCH_DEFAULT
@@ -369,10 +364,12 @@ static int bootm_find_other(struct cmd_tbl *cmdtp, int flag, int argc,
*
* @comp_type: Compression type being used (IH_COMP_...)
* @uncomp_size: Number of bytes uncompressed
+ * @buf_size: Number of bytes the decompresion buffer was
* @ret: errno error code received from compression library
* Return: Appropriate BOOTM_ERR_ error code
*/
-static int handle_decomp_error(int comp_type, size_t uncomp_size, int ret)
+static int handle_decomp_error(int comp_type, size_t uncomp_size,
+ size_t buf_size, int ret)
{
const char *name = genimg_get_comp_name(comp_type);
@@ -380,7 +377,7 @@ static int handle_decomp_error(int comp_type, size_t uncomp_size, int ret)
if (ret == -ENOSYS)
return BOOTM_ERR_UNIMPLEMENTED;
- if (uncomp_size >= CONFIG_SYS_BOOTM_LEN)
+ if (uncomp_size >= buf_size)
printf("Image too large: increase CONFIG_SYS_BOOTM_LEN\n");
else
printf("%s: uncompress error %d\n", name, ret);
@@ -420,7 +417,8 @@ static int bootm_load_os(bootm_headers_t *images, int boot_progress)
load_buf, image_buf, image_len,
CONFIG_SYS_BOOTM_LEN, &load_end);
if (err) {
- err = handle_decomp_error(os.comp, load_end - load, err);
+ err = handle_decomp_error(os.comp, load_end - load,
+ CONFIG_SYS_BOOTM_LEN, err);
bootstage_error(BOOTSTAGE_ID_DECOMP_IMAGE);
return err;
}
@@ -1006,7 +1004,7 @@ static int bootm_host_load_image(const void *fit, int req_image_type,
ulong data, len;
bootm_headers_t images;
int noffset;
- ulong load_end;
+ ulong load_end, buf_size;
uint8_t image_type;
uint8_t imape_comp;
void *load_buf;
@@ -1032,14 +1030,14 @@ static int bootm_host_load_image(const void *fit, int req_image_type,
}
/* Allow the image to expand by a factor of 4, should be safe */
- load_buf = malloc((1 << 20) + len * 4);
+ buf_size = (1 << 20) + len * 4;
+ load_buf = malloc(buf_size);
ret = image_decomp(imape_comp, 0, data, image_type, load_buf,
- (void *)data, len, CONFIG_SYS_BOOTM_LEN,
- &load_end);
+ (void *)data, len, buf_size, &load_end);
free(load_buf);
if (ret) {
- ret = handle_decomp_error(imape_comp, load_end - 0, ret);
+ ret = handle_decomp_error(imape_comp, load_end - 0, buf_size, ret);
if (ret != BOOTM_ERR_UNIMPLEMENTED)
return ret;
}