Skip to content

Commit 119d17d

Browse files
SeppoTakalorlubos
authored andcommitted
net: lwm2m_client_utils: Don't return unknown FOTA errors
We should take care to not return any other error than what lwm2m_obj_firmware.c handles. If we for example return -EACCESS, then LwM2M content format writer ignores that as it is supposed to skip over write requests to read-only resources. So we now default to -EFAULT, so we don't cause any undefined behaviour. Signed-off-by: Seppo Takalo <[email protected]>
1 parent 4878240 commit 119d17d

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

subsys/net/lib/lwm2m_client_utils/lwm2m/lwm2m_firmware.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -845,6 +845,24 @@ static int firmware_block_received_cb(uint16_t obj_inst_id, uint16_t res_id, uin
845845
if (dfu_target_reset() < 0) {
846846
LOG_ERR("Failed to reset DFU target");
847847
}
848+
/* We must return only known values for LwM2M firmware handler. */
849+
switch (ret) {
850+
case -ENOMEM:
851+
case -ENOSPC:
852+
case -EFAULT:
853+
case -ENOMSG:
854+
break;
855+
case -EFBIG:
856+
case -E2BIG:
857+
ret = -ENOSPC;
858+
break;
859+
case -EINVAL:
860+
ret = -ENOMSG;
861+
break;
862+
default:
863+
ret = -EFAULT;
864+
break;
865+
}
848866
}
849867

850868
return ret;

0 commit comments

Comments
 (0)