Skip to content

Commit 33173b0

Browse files
SeppoTakalorlubos
authored andcommitted
[nrf fromlist] net: lwm2m: Fix null dereference when post-write cb is set
When opaque resources have post-write callback set, but the write is not a Block-Wise write, there is no block_ctx and the code causes null pointer dereference when calculating the offset of the data. Upstream PR: zephyrproject-rtos/zephyr#73162 Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no> Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
1 parent 5e11b5f commit 33173b0

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

subsys/net/lib/lwm2m/lwm2m_message_handling.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -996,10 +996,10 @@ static int lwm2m_write_handler_opaque(struct lwm2m_engine_obj_inst *obj_inst,
996996
#endif /* CONFIG_LWM2M_ENGINE_VALIDATION_BUFFER_SIZE > 0 */
997997

998998
if (res->post_write_cb) {
999-
ret = res->post_write_cb(obj_inst->obj_inst_id, res->res_id,
1000-
res_inst->res_inst_id, data_ptr, len,
1001-
last_pkt_block && last_block, opaque_ctx.len,
1002-
msg->in.block_ctx->ctx.current);
999+
ret = res->post_write_cb(
1000+
obj_inst->obj_inst_id, res->res_id, res_inst->res_inst_id, data_ptr,
1001+
len, last_pkt_block && last_block, opaque_ctx.len,
1002+
(msg->in.block_ctx ? msg->in.block_ctx->ctx.current : 0));
10031003
if (ret < 0) {
10041004
return ret;
10051005
}

0 commit comments

Comments
 (0)