Skip to contentSkip to conversation

'bootz' command fails to load the zImage's header

PATCH Applied Juergen Beisert 2 participants 3 messages Oct 14, 2011 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 'bootz' command fails to load the zImage's header

Running the 'bootz' command always fails with

could not read <some file>

due to it loads only a size of a pointer, instead of the size of the expected header structure.

arch/arm/lib/bootz.c +1 -1
index fc14487..9be615b 100644
@@ -53,7 +53,7 @@ static int do_bootz(struct command *cmdtp, int argc, char *argv[])
 
 	if (!usemap) {
 		header = &__header;
-		ret = read(fd, header, sizeof(header));
+		ret = read(fd, header, sizeof(*header));
 		if (ret < sizeof(*header)) {
 			printf("could not read %s\n", argv[1]);
 			goto err_out;
Signature · 7 lines
Pengutronix e.K.                              | Juergen Beisert             |
Linux Solutions for Science and Industry      | http://www.pengutronix.de/  |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Applied
#1 lore raw
Quoted 6 lines · Juergen Beisert

Running the 'bootz' command always fails with

could not read <some file>

due to it loads only a size of a pointer, instead of the size of the expected header structure.

Applied to master instead which also has this bug. Unfortunately this bug is also in the october release.

Sascha

Quoted 26 lines
arch/arm/lib/bootz.c +1 -1
index fc14487..9be615b 100644
@@ -53,7 +53,7 @@ static int do_bootz(struct command *cmdtp, int argc, char *argv[])
 
 	if (!usemap) {
 		header = &__header;
-		ret = read(fd, header, sizeof(header));
+		ret = read(fd, header, sizeof(*header));
 		if (ret < sizeof(*header)) {
 			printf("could not read %s\n", argv[1]);
 			goto err_out;
Signature · 8 lines
-- 
Pengutronix e.K.                              | Juergen Beisert             |
Linux Solutions for Science and Industry      | http://www.pengutronix.de/  |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#2 lore raw

PATCH 1/1 Really fix the 'bootz' command

Running the 'bootz' command always fails with

could not read <some file>

due to wrong usage of pointers and structures. This is the second try to fix the 'bootz' command. At least on my target it is now be able again to load a kernel without any error.

arch/arm/lib/bootz.c +3 -3
index 9be615b..956ea82 100644
@@ -89,10 +89,10 @@ static int do_bootz(struct command *cmdtp, int argc, char *argv[])
 			}
 		}
 
-		memcpy(zimage, &header, sizeof(header));
+		memcpy(zimage, header, sizeof(*header));
 
-		ret = read(fd, zimage + sizeof(header), end - sizeof(header));
-		if (ret < end - sizeof(header)) {
+		ret = read(fd, zimage + sizeof(*header), end - sizeof(*header));
+		if (ret < end - sizeof(*header)) {
 			printf("could not read %s\n", argv[1]);
 			goto err_out1;
 		}
Signature · 7 lines
Pengutronix e.K.                              | Juergen Beisert             |
Linux Solutions for Science and Industry      | http://www.pengutronix.de/  |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox