public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot-Users] [PATCH v3] Fix initrd length miscalculation in bootm command when using a dtu
@ 2007-05-03 22:30 Timur Tabi
  2007-05-03 23:47 ` Wolfgang Denk
  0 siblings, 1 reply; 15+ messages in thread
From: Timur Tabi @ 2007-05-03 22:30 UTC (permalink / raw)
  To: u-boot

The do_bootm_linux() function uses the same variable ('len') to calculate the
dtu (flat device tree wrapped in a uImage) length and the initrd length, which
means that the initrd length was incorrect when it was needed.  This patch
changes any code that uses 'len' or 'data' as temporary variables to use
the values directly instead.  It also adds a comment to the definitions
of 'len' and 'data' reminding other programmers what they represent.

Signed-off-by: Timur Tabi <timur@freescale.com>
---

This patch is a simplied version of the initrd patch that only fixes the root
problem, without renaming any variables.  This bug was introduced in commit
87a449c8ac396420cb24260f717ea9e6faa82047.

 common/cmd_bootm.c |   12 ++++--------
 1 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
index 32c29e5..bd6d1c9 100644
--- a/common/cmd_bootm.c
+++ b/common/cmd_bootm.c
@@ -523,11 +523,11 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int flag,
 		int	verify)
 {
 	ulong	sp;
-	ulong	len, checksum;
+	ulong	len, data;	/* The initrd length and address */
 	ulong	initrd_start, initrd_end;
 	ulong	cmd_start, cmd_end;
 	ulong	initrd_high;
-	ulong	data;
+	ulong	checksum;
 	int	initrd_copy_to_ram = 1;
 	char    *cmdline;
 	char	*s;
@@ -652,13 +652,10 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int flag,
 			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);
@@ -779,9 +776,8 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int flag,

 			checksum = ntohl(hdr->ih_dcrc);
 			addr = (ulong)((uchar *)(hdr) + sizeof(image_header_t));
-			len = ntohl(hdr->ih_size);

-			if(checksum != crc32(0, (uchar *)addr, len)) {
+			if(checksum != crc32(0, (uchar *)addr, ntohl(hdr->ih_size))) {
 				printf("ERROR: Flat Device Tree checksum is invalid\n");
 				return;
 			}
--
1.5.0.2.260.g2eb065

^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2007-05-04 21:58 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-05-03 22:30 [U-Boot-Users] [PATCH v3] Fix initrd length miscalculation in bootm command when using a dtu Timur Tabi
2007-05-03 23:47 ` Wolfgang Denk
2007-05-04  1:13   ` Timur Tabi
2007-05-04  8:28     ` Wolfgang Denk
2007-05-04 13:25       ` Timur Tabi
2007-05-04 13:46         ` Stefan Roese
2007-05-04 14:22           ` Jerry Van Baren
2007-05-04 16:02             ` Timur Tabi
2007-05-04 16:07               ` Jerry Van Baren
2007-05-04 15:57           ` Timur Tabi
2007-05-04 16:27         ` Wolfgang Denk
2007-05-04 16:32           ` Timur Tabi
2007-05-04 19:28             ` Wolfgang Denk
2007-05-04 19:40               ` Timur Tabi
2007-05-04 21:58               ` Timur Tabi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox