mgmt: mcumgt: smp: Fix not checking returned status
Fixes not checking if a zcbor operation was successful. Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
This commit is contained in:
parent
d98656f081
commit
c9a4764c10
|
@ -226,12 +226,18 @@ static int smp_handle_single_payload(struct smp_streamer *cbuf, const struct smp
|
|||
}
|
||||
|
||||
if (handler_fn) {
|
||||
bool ok;
|
||||
|
||||
*handler_found = true;
|
||||
zcbor_map_start_encode(cbuf->writer->zs,
|
||||
CONFIG_MCUMGR_SMP_CBOR_MAX_MAIN_MAP_ENTRIES);
|
||||
ok = zcbor_map_start_encode(cbuf->writer->zs,
|
||||
CONFIG_MCUMGR_SMP_CBOR_MAX_MAIN_MAP_ENTRIES);
|
||||
|
||||
MGMT_CTXT_SET_RC_RSN(cbuf, NULL);
|
||||
|
||||
if (!ok) {
|
||||
return MGMT_ERR_EMSGSIZE;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_MCUMGR_SMP_COMMAND_STATUS_HOOKS)
|
||||
cmd_recv.group = req_hdr->nh_group;
|
||||
cmd_recv.id = req_hdr->nh_id;
|
||||
|
@ -248,8 +254,8 @@ static int smp_handle_single_payload(struct smp_streamer *cbuf, const struct smp
|
|||
if (status == MGMT_CB_ERROR_RC) {
|
||||
rc = ret_rc;
|
||||
} else {
|
||||
bool ok = smp_add_cmd_ret(cbuf->writer->zs, ret_group,
|
||||
(uint16_t)ret_rc);
|
||||
ok = smp_add_cmd_ret(cbuf->writer->zs, ret_group,
|
||||
(uint16_t)ret_rc);
|
||||
|
||||
rc = (ok ? MGMT_ERR_EOK : MGMT_ERR_EMSGSIZE);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue