Skip to content

Commit ef9d8f4

Browse files
committed
fix(ipc): guard LOG_D against null thread pointer in rt_susp_list_dequeue
When rt_susp_list_dequeue() returns RT_NULL (empty suspended list), the LOG_D call dereferenced thread->parent.name without a null check, causing a crash in debug builds. Per @wdfk-prog review feedback, push the null check into the LOG_D argument using a ternary so the entire expression — including the null check — is compiled out when LOG_D is disabled. This avoids an unnecessary runtime branch in release builds. Also fix a typo in the change-log header: 'redesigen' -> 'redesign'. Signed-off-by: Srikanth Patchava <srpatcha@users.noreply.github.com>
1 parent 96c0ce2 commit ef9d8f4

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/ipc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
* 2022-04-08 Stanley Correct descriptions
4545
* 2022-10-15 Bernard add nested mutex feature
4646
* 2022-10-16 Bernard add prioceiling feature in mutex
47-
* 2023-04-16 Xin-zheqi redesigen queue recv and send function return real message size
47+
* 2023-04-16 Xin-zheqi redesign queue recv and send function return real message size
4848
* 2023-09-15 xqyjlj perf rt_hw_interrupt_disable/enable
4949
*/
5050

@@ -140,7 +140,7 @@ struct rt_thread *rt_susp_list_dequeue(rt_list_t *susp_list, rt_err_t thread_err
140140
}
141141
rt_sched_unlock(slvl);
142142

143-
LOG_D("resume thread:%s\n", thread->parent.name);
143+
LOG_D("resume thread:%s\n", (thread == RT_NULL) ? "NULL" : thread->parent.name);
144144

145145
return thread;
146146
}

0 commit comments

Comments
 (0)