[U-Boot-Users] [DNX#2007020542000011] [PATCH] Fix initrd length miscalculation in bootm [...]

OTRS Notification Master otrs at denx.de
Mon Feb 5 20:40:04 CET 2007


Hello list,

inside the automatic U-Boot patch tracking system a new ticket
[DNX#2007020542000011] was created:

<snip>
> The do_bootm_linux() function was using the same variable ('len') to
> calculate
> the the dtu length and the initrd length, which meant that the initrd
> length
> was incorrect.  This patch creates renames 'len' and 'data' to
> 'initrd_len'
> and 'initrd_data', thereby preventing any future confusion.  It also
> deletes
> 'len' and 'data' because the dtu calculations don't actually need them.
> 
> Signed-off-by: Timur Tabi <timur at freescale.com>
> ---
>  common/cmd_bootm.c |   57
> +++++++++++++++++++++++----------------------------
>  1 files changed, 26 insertions(+), 31 deletions(-)
> 
> diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
> index 7aae8a6..0c092c7 100644
> --- a/common/cmd_bootm.c
> +++ b/common/cmd_bootm.c
> @@ -518,11 +518,10 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int fl
>  		int	verify)
>  {
>  	ulong	sp;
> -	ulong	len, checksum;
> -	ulong	initrd_start, initrd_end;
> +	ulong	checksum;
> +	ulong	initrd_start, initrd_end, initrd_data, initrd_len;
>  	ulong	cmd_start, cmd_end;
>  	ulong	initrd_high;
> -	ulong	data;
>  	int	initrd_copy_to_ram = 1;
>  	char    *cmdline;
>  	char	*s;
> @@ -626,7 +625,7 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int fl
>  	/* Look for a '-' which indicates to ignore the ramdisk argument */
>  	if (argc >= 3 && strcmp(argv[2], "-") ==  0) {
>  			debug ("Skipping initrd\n");
> -			len = data = 0;
> +			initrd_len = initrd_data = 0;
>  		}
>  	else
>  #endif
> @@ -647,13 +646,10 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int fl
>  			do_reset (cmdtp, flag, argc, argv);
>  		}
>  
> -		data = (ulong)&header;
> -		len  = sizeof(image_header_t);
> -
>  		checksum = ntohl(hdr->ih_hcrc);
>  		hdr->ih_hcrc = 0;
>  
> -		if (crc32 (0, (uchar *)data, len) != checksum) {
> +		if (crc32 (0, (uchar *) &header, sizeof(image_header_t)) != checksum)
> {
>  			puts ("Bad Header Checksum\n");
>  			SHOW_BOOT_PROGRESS (-11);
>  			do_reset (cmdtp, flag, argc, argv);
> @@ -663,13 +659,13 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int fl
>  
>  		print_image_hdr (hdr);
>  
> -		data = addr + sizeof(image_header_t);
> -		len  = ntohl(hdr->ih_size);
> +		initrd_data = addr + sizeof(image_header_t);
> +		initrd_len  = ntohl(hdr->ih_size);
>  
>  		if (verify) {
>  			ulong csum = 0;
>  #if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
> -			ulong cdata = data, edata = cdata + len;
> +			ulong cdata = initrd_data, edata = cdata + initrd_len;
>  #endif	/* CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG */
>  
>  			puts ("   Verifying Checksum ... ");
> @@ -687,7 +683,7 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int fl
>  				WATCHDOG_RESET();
>  			}
>  #else	/* !(CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG) */
> -			csum = crc32 (0, (uchar *)data, len);
> +			csum = crc32 (0, (uchar *) initrd_data, initrd_len);
>  #endif	/* CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG */
>  
>  			if (csum != ntohl(hdr->ih_dcrc)) {
> @@ -718,17 +714,17 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int fl
>  		SHOW_BOOT_PROGRESS (13);
>  
>  		/* skip kernel length and terminator */
> -		data = (ulong)(&len_ptr[2]);
> +		initrd_data = (ulong)(&len_ptr[2]);
>  		/* skip any additional image length fields */
>  		for (i=1; len_ptr[i]; ++i)
> -			data += 4;
> +			initrd_data += 4;
>  		/* add kernel length, and align */
> -		data += ntohl(len_ptr[0]);
> +		initrd_data += ntohl(len_ptr[0]);
>  		if (tail) {
> -			data += 4 - tail;
</snip>

Your U-Boot support team



More information about the U-Boot mailing list