net: lwm2m: check engine context before accessing it
Signed-off-by: Robert Chou <robert.ch.chou@acer.com>
This commit is contained in:
parent
6ca3cc6fc4
commit
d36b3251fa
1 changed files with 13 additions and 5 deletions
|
@ -1730,8 +1730,8 @@ static int lwm2m_read_handler(struct lwm2m_engine_obj_inst *obj_inst,
|
|||
struct lwm2m_engine_obj_field *obj_field,
|
||||
struct lwm2m_engine_context *context)
|
||||
{
|
||||
struct lwm2m_output_context *out = context->out;
|
||||
struct lwm2m_obj_path *path = context->path;
|
||||
struct lwm2m_output_context *out;
|
||||
struct lwm2m_obj_path *path;
|
||||
int i, loop_max = 1;
|
||||
u16_t res_inst_id_tmp = 0;
|
||||
void *data_ptr = NULL;
|
||||
|
@ -1741,6 +1741,9 @@ static int lwm2m_read_handler(struct lwm2m_engine_obj_inst *obj_inst,
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
out = context->out;
|
||||
path = context->path;
|
||||
|
||||
/* setup initial data elements */
|
||||
data_ptr = res->data_ptr;
|
||||
data_len = res->data_len;
|
||||
|
@ -1918,8 +1921,8 @@ int lwm2m_write_handler(struct lwm2m_engine_obj_inst *obj_inst,
|
|||
struct lwm2m_engine_obj_field *obj_field,
|
||||
struct lwm2m_engine_context *context)
|
||||
{
|
||||
struct lwm2m_input_context *in = context->in;
|
||||
struct lwm2m_obj_path *path = context->path;
|
||||
struct lwm2m_input_context *in;
|
||||
struct lwm2m_obj_path *path;
|
||||
s64_t temp64 = 0;
|
||||
s32_t temp32 = 0;
|
||||
void *data_ptr = NULL;
|
||||
|
@ -1936,6 +1939,9 @@ int lwm2m_write_handler(struct lwm2m_engine_obj_inst *obj_inst,
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
in = context->in;
|
||||
path = context->path;
|
||||
|
||||
/* setup initial data elements */
|
||||
data_ptr = res->data_ptr;
|
||||
data_len = res->data_len;
|
||||
|
@ -2081,7 +2087,7 @@ static int lwm2m_write_attr_handler(struct lwm2m_engine_obj *obj,
|
|||
static int lwm2m_exec_handler(struct lwm2m_engine_obj *obj,
|
||||
struct lwm2m_engine_context *context)
|
||||
{
|
||||
struct lwm2m_obj_path *path = context->path;
|
||||
struct lwm2m_obj_path *path;
|
||||
struct lwm2m_engine_obj_inst *obj_inst;
|
||||
struct lwm2m_engine_res_inst *res = NULL;
|
||||
int ret;
|
||||
|
@ -2090,6 +2096,8 @@ static int lwm2m_exec_handler(struct lwm2m_engine_obj *obj,
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
path = context->path;
|
||||
|
||||
obj_inst = get_engine_obj_inst(path->obj_id, path->obj_inst_id);
|
||||
if (!obj_inst) {
|
||||
return -ENOENT;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue