Skip to content

Commit bad6ab8

Browse files
committed
nimble/ll: Fix NULL pointer dereference in ble_ll_sched_rmv_elem_type
This fixes possible NULL pointer dereference in ble_ll_sched_rmv_elem_type that could happen if 'g_ble_ll_sched_q' queue is empty. Uninitialized 'first_removed' variable has been fixed as well.
1 parent 3bb2671 commit bad6ab8

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

nimble/controller/src/ble_ll_sched.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -930,10 +930,13 @@ ble_ll_sched_rmv_elem_type(uint8_t type, sched_remove_cb_func remove_cb)
930930
OS_ENTER_CRITICAL(sr);
931931

932932
first = TAILQ_FIRST(&g_ble_ll_sched_q);
933-
if (first->sched_type == type) {
934-
first_removed = 1;
933+
if (!first) {
934+
OS_EXIT_CRITICAL(sr);
935+
return;
935936
}
936937

938+
first_removed = first->sched_type == type;
939+
937940
TAILQ_FOREACH(entry, &g_ble_ll_sched_q, link) {
938941
if (entry->sched_type != type) {
939942
continue;

0 commit comments

Comments
 (0)