Skip to content

Commit 32f69a4

Browse files
nordicjmnashif
authored andcommitted
mgmt: mcumgr: grp: img_mgmt: Fix calling confirm
Fixes calling the registered callbacks for image being confirmed if the confirmation was not successful Signed-off-by: Jamie McCrae <[email protected]> (cherry picked from commit 98d5aa3)
1 parent 28f1398 commit 32f69a4

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

subsys/mgmt/mcumgr/grp/img_mgmt/src/img_mgmt_state.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -391,11 +391,6 @@ img_mgmt_state_confirm(void)
391391
{
392392
int rc;
393393

394-
#if defined(CONFIG_MCUMGR_GRP_IMG_STATUS_HOOKS)
395-
int32_t err_rc;
396-
uint16_t err_group;
397-
#endif
398-
399394
/* Confirm disallowed if a test is pending. */
400395
if (img_mgmt_state_any_pending()) {
401396
rc = IMG_MGMT_ERR_IMAGE_ALREADY_PENDING;
@@ -405,8 +400,13 @@ img_mgmt_state_confirm(void)
405400
rc = img_mgmt_write_confirmed();
406401

407402
#if defined(CONFIG_MCUMGR_GRP_IMG_STATUS_HOOKS)
408-
(void)mgmt_callback_notify(MGMT_EVT_OP_IMG_MGMT_DFU_CONFIRMED, NULL, 0, &err_rc,
409-
&err_group);
403+
if (!rc) {
404+
int32_t err_rc;
405+
uint16_t err_group;
406+
407+
(void)mgmt_callback_notify(MGMT_EVT_OP_IMG_MGMT_DFU_CONFIRMED, NULL, 0, &err_rc,
408+
&err_group);
409+
}
410410
#endif
411411

412412
err:

0 commit comments

Comments
 (0)