From 72341c3c8bb4e0187cd03d556637e000c4c3a25b Mon Sep 17 00:00:00 2001 From: Ali Mashtizadeh Date: Sat, 2 Sep 2023 18:41:20 -0400 Subject: [PATCH] Fix WaitChannel_Wake to do nothing if there's no threads to wake up. --- sys/kern/waitchannel.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sys/kern/waitchannel.c b/sys/kern/waitchannel.c index 941751b..1d50547 100644 --- a/sys/kern/waitchannel.c +++ b/sys/kern/waitchannel.c @@ -92,9 +92,11 @@ WaitChannel_Wake(WaitChannel *wchan) Spinlock_Lock(&wchan->lock); thr = TAILQ_FIRST(&wchan->chanQueue); - TAILQ_REMOVE(&wchan->chanQueue, thr, chanQueue); - Sched_SetRunnable(thr); - Thread_Release(thr); + if (thr != NULL) { + TAILQ_REMOVE(&wchan->chanQueue, thr, chanQueue); + Sched_SetRunnable(thr); + Thread_Release(thr); + } Spinlock_Unlock(&wchan->lock); }