Skip to content

Commit 194b363

Browse files
committed
Reset hdr_ok when image open fails
F/2578
1 parent 9421355 commit 194b363

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

src/image.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1383,9 +1383,7 @@ int wolfBoot_get_dts_size(void *dts_addr)
13831383
*/
13841384
int wolfBoot_open_image(struct wolfBoot_image *img, uint8_t part)
13851385
{
1386-
#ifdef MMU
13871386
int ret;
1388-
#endif
13891387
uint8_t *image;
13901388
if (!img)
13911389
return -1;
@@ -1441,8 +1439,10 @@ int wolfBoot_open_image(struct wolfBoot_image *img, uint8_t part)
14411439
else
14421440
image = (uint8_t *)img->hdr;
14431441
img->hdr_ok = 1;
1444-
1445-
return wolfBoot_open_image_address(img, image);
1442+
ret = wolfBoot_open_image_address(img, image);
1443+
if (ret != 0)
1444+
img->hdr_ok = 0;
1445+
return ret;
14461446
}
14471447

14481448

tools/unit-tests/unit-image.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,7 @@ START_TEST(test_open_image)
835835
ext_flash_erase(0, WOLFBOOT_SECTOR_SIZE);
836836
ret = wolfBoot_open_image(&img, PART_UPDATE);
837837
ck_assert_int_eq(ret, -1);
838+
ck_assert_uint_eq(img.hdr_ok, 0);
838839

839840
/* Swap partition */
840841
ret = wolfBoot_open_image(&img, PART_SWAP);

0 commit comments

Comments
 (0)