net: mgmt: Handle loops in the linked list
In case the same callback handler is added to the list twice, this can result in a loop. Fixes: #69825. Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
This commit is contained in:
parent
39f710136e
commit
0a8cbb6a22
|
@ -338,6 +338,9 @@ void net_mgmt_add_event_callback(struct net_mgmt_event_callback *cb)
|
|||
|
||||
(void)k_mutex_lock(&net_mgmt_callback_lock, K_FOREVER);
|
||||
|
||||
/* Remove the callback if it already exists to avoid loop */
|
||||
sys_slist_find_and_remove(&event_callbacks, &cb->node);
|
||||
|
||||
sys_slist_prepend(&event_callbacks, &cb->node);
|
||||
|
||||
mgmt_add_event_mask(cb->event_mask);
|
||||
|
|
Loading…
Reference in a new issue