This is an automated email from the ASF dual-hosted git repository. utzig pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/mynewt-mcumgr.git
commit e215d26bb7c7ea1352bc954b2b59a6fc0a234a46 Author: Dominik Ermel <dominik.er...@nordicsemi.no> AuthorDate: Wed Jun 9 13:51:18 2021 +0000 zephyr: Check area id in erase slot processing The img_mgmt_impl_erase_slot was not checking the return value of the img_mgmt_find_best_area_id. Signed-off-by: Dominik Ermel <dominik.er...@nordicsemi.no> --- cmd/img_mgmt/port/zephyr/src/zephyr_img_mgmt.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cmd/img_mgmt/port/zephyr/src/zephyr_img_mgmt.c b/cmd/img_mgmt/port/zephyr/src/zephyr_img_mgmt.c index 25b9318..9eb9450 100644 --- a/cmd/img_mgmt/port/zephyr/src/zephyr_img_mgmt.c +++ b/cmd/img_mgmt/port/zephyr/src/zephyr_img_mgmt.c @@ -192,11 +192,13 @@ int img_mgmt_impl_erase_slot(void) { bool empty; - int rc; + int rc, best_id; /* Select non-active slot */ - const int best_id = img_mgmt_find_best_area_id(); - + best_id = img_mgmt_find_best_area_id(); + if (best_id < 0) { + return MGMT_ERR_EUNKNOWN; + } rc = zephyr_img_mgmt_flash_check_empty(best_id, &empty); if (rc != 0) { return MGMT_ERR_EUNKNOWN;