Add a check for the case when the parent neighbor may have gone away to avoid using a NULL pointer
This commit is contained in:
parent
0ed7db0f9b
commit
490791eaa4
@ -553,13 +553,17 @@ rpl_add_parent(rpl_dag_t *dag, rpl_dio_t *dio, uip_ipaddr_t *addr)
|
|||||||
if(lladdr != NULL) {
|
if(lladdr != NULL) {
|
||||||
/* Add parent in rpl_parents */
|
/* Add parent in rpl_parents */
|
||||||
p = nbr_table_add_lladdr(rpl_parents, (rimeaddr_t *)lladdr);
|
p = nbr_table_add_lladdr(rpl_parents, (rimeaddr_t *)lladdr);
|
||||||
p->dag = dag;
|
if(p == NULL) {
|
||||||
p->rank = dio->rank;
|
PRINTF("RPL: rpl_add_parent p NULL\n");
|
||||||
p->dtsn = dio->dtsn;
|
} else {
|
||||||
p->link_metric = RPL_INIT_LINK_METRIC * RPL_DAG_MC_ETX_DIVISOR;
|
p->dag = dag;
|
||||||
|
p->rank = dio->rank;
|
||||||
|
p->dtsn = dio->dtsn;
|
||||||
|
p->link_metric = RPL_INIT_LINK_METRIC * RPL_DAG_MC_ETX_DIVISOR;
|
||||||
#if RPL_DAG_MC != RPL_DAG_MC_NONE
|
#if RPL_DAG_MC != RPL_DAG_MC_NONE
|
||||||
memcpy(&p->mc, &dio->mc, sizeof(p->mc));
|
memcpy(&p->mc, &dio->mc, sizeof(p->mc));
|
||||||
#endif /* RPL_DAG_MC != RPL_DAG_MC_NONE */
|
#endif /* RPL_DAG_MC != RPL_DAG_MC_NONE */
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return p;
|
return p;
|
||||||
|
Loading…
Reference in New Issue
Block a user