mgmt/mcumgr: Fix image erase returning improper error code on error

The img_mgmt_erase could return MGMT_ERR_EOK even when
img_mgmt_impl_erase_slot failed.

Fixes #50522

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
This commit is contained in:
Dominik Ermel 2022-09-22 10:13:05 +00:00 committed by Fabio Baltieri
parent ce1377c5ee
commit e4d0bf0e64

View File

@ -279,17 +279,16 @@ img_mgmt_erase(struct mgmt_ctxt *ctxt)
}
rc = img_mgmt_impl_erase_slot(slot);
if (rc != 0) {
img_mgmt_dfu_stopped();
return rc;
}
if (rc == 0) {
ok = zcbor_tstr_put_lit(zse, "rc") &&
zcbor_int32_put(zse, 0);
if (zcbor_tstr_put_lit(zse, "rc") && zcbor_int32_put(zse, 0)) {
return MGMT_ERR_EOK;
}
return ok ? MGMT_ERR_EOK : MGMT_ERR_EMSGSIZE;
return MGMT_ERR_EMSGSIZE;
}
static int