lib: updatehub: Add flash_img_init return value check

The flash_img_int return value is not checked for fail conditions.
This can result on useless download attempts once image will not
be properly recorded. Add return value check and on error execute
default treatment.

Fixes #26992.

Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
This commit is contained in:
Gerson Fernando Budke 2020-07-28 23:44:56 -03:00 committed by Carles Cufí
commit 32bafacc31

View file

@ -501,7 +501,11 @@ static enum updatehub_response install_update(void)
goto cleanup;
}
flash_img_init(&ctx.flash_ctx);
if (flash_img_init(&ctx.flash_ctx)) {
LOG_ERR("Unable init flash");
ctx.code_status = UPDATEHUB_FLASH_INIT_ERROR;
goto cleanup;
}
ctx.downloaded_size = 0;
updatehub_blk_set(UPDATEHUB_BLK_ATTEMPT, 0);