Unverified Commit ef802e49 authored by Maxime Ripard's avatar Maxime Ripard
Browse files

fel: Check for the U-Boot header CRC



A U-Boot image has two CRCs, one to cover the data and that we already
check, and one to cover the header.

Since we're not checking the latter, let's make sure it's the case.
Tested-by: default avatarFrank Kunz <mailinglists@kunz-im-inter.net>
Signed-off-by: default avatarMaxime Ripard <maxime.ripard@free-electrons.com>
parent e753821e
......@@ -764,6 +764,15 @@ void aw_fel_write_uboot_image(feldev_handle *dev, uint8_t *buf, size_t len)
image_header_t hdr = *(image_header_t *)buf;
uint32_t hcrc = be32toh(hdr.ih_hcrc);
/* The CRC is calculated on the whole header but the CRC itself */
hdr.ih_hcrc = 0;
uint32_t computed_hcrc = crc32(0, (const uint8_t *) &hdr, HEADER_SIZE);
if (hcrc != computed_hcrc)
pr_fatal("U-Boot header CRC mismatch: expected %x, got %x\n",
hcrc, computed_hcrc);
/* Check for a valid mkimage header */
int image_type = get_image_type(buf, len);
if (image_type <= IH_TYPE_INVALID) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment