Skip to content

Commit

Permalink
mgmt/mcumgr: Fix failure to confirm active image not reported
Browse files Browse the repository at this point in the history
Due to broken logic in img_mgmt_state_confirm failure to confirm
was not reported to caller.
If hooks were enabled confirmation event would be passed regardless
whether it has been successful.

Fixes zephyrproject-rtos#56617

Signed-off-by: Dominik Ermel <[email protected]>
  • Loading branch information
de-nordic authored and carlescufi committed Apr 24, 2023
1 parent 20e142c commit a48e6b9
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions subsys/mgmt/mcumgr/grp/img_mgmt/src/img_mgmt_state.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,24 +178,19 @@ img_mgmt_state_set_pending(int slot, int permanent)
int
img_mgmt_state_confirm(void)
{
int rc;

/* Confirm disallowed if a test is pending. */
if (img_mgmt_state_any_pending()) {
rc = MGMT_ERR_EBADSTATE;
goto err;
if (img_mgmt_state_any_pending() != 0) {
return MGMT_ERR_EBADSTATE;
}

rc = img_mgmt_write_confirmed();
if (rc != 0) {
rc = MGMT_ERR_EUNKNOWN;
if (img_mgmt_write_confirmed() != 0) {
return MGMT_ERR_EUNKNOWN;
}

#if defined(CONFIG_MCUMGR_GRP_IMG_STATUS_HOOKS)
(void)mgmt_callback_notify(MGMT_EVT_OP_IMG_MGMT_DFU_CONFIRMED, NULL, 0);
#endif

err:
return 0;
}

Expand Down

0 comments on commit a48e6b9

Please sign in to comment.