Skip to content

Commit

Permalink
bootutil: loader: Add state to boot_is_header_valid() function
Browse files Browse the repository at this point in the history
Adds the state object to this function so it can be referenced

Signed-off-by: Jamie McCrae <[email protected]>
  • Loading branch information
nordicjm committed Aug 22, 2024
1 parent 6071ceb commit 3f07bdc
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions boot/bootutil/src/loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -863,10 +863,13 @@ split_image_check(struct image_header *app_hdr,
* within the flash area we are in.
*/
static bool
boot_is_header_valid(const struct image_header *hdr, const struct flash_area *fap)
boot_is_header_valid(const struct image_header *hdr, const struct flash_area *fap,
struct boot_loader_state *state)
{
uint32_t size;

(void)state;

if (hdr->ih_magic != IMAGE_MAGIC) {
return false;
}
Expand Down Expand Up @@ -1033,7 +1036,7 @@ boot_validate_slot(struct boot_loader_state *state, int slot,
{
FIH_CALL(boot_image_check, fih_rc, state, hdr, fap, bs);
}
if (!boot_is_header_valid(hdr, fap) || FIH_NOT_EQ(fih_rc, FIH_SUCCESS)) {
if (!boot_is_header_valid(hdr, fap, state) || FIH_NOT_EQ(fih_rc, FIH_SUCCESS)) {
if ((slot != BOOT_PRIMARY_SLOT) || ARE_SLOTS_EQUIVALENT()) {
flash_area_erase(fap, 0, flash_area_get_size(fap));
/* Image is invalid, erase it to prevent further unnecessary
Expand Down Expand Up @@ -2556,7 +2559,7 @@ boot_get_slot_usage(struct boot_loader_state *state)
for (slot = 0; slot < BOOT_NUM_SLOTS; slot++) {
hdr = boot_img_hdr(state, slot);

if (boot_is_header_valid(hdr, BOOT_IMG_AREA(state, slot))) {
if (boot_is_header_valid(hdr, BOOT_IMG_AREA(state, slot), state)) {
state->slot_usage[BOOT_CURR_IMG(state)].slot_available[slot] = true;
BOOT_LOG_IMAGE_INFO(slot, hdr);
} else {
Expand Down

0 comments on commit 3f07bdc

Please sign in to comment.