diff --git a/kernel/locking/mutex.c b/kernel/locking/mutex.c index dadbf88c22c48cea044aac4e34fda9deec78636a..454195194d4a133f2d600d0d3659b2ee5306b7ad 100644 --- a/kernel/locking/mutex.c +++ b/kernel/locking/mutex.c @@ -378,8 +378,14 @@ static bool mutex_optimistic_spin(struct mutex *lock, * reschedule now, before we try-lock the mutex. This avoids getting * scheduled out right after we obtained the mutex. */ - if (need_resched()) + if (need_resched()) { + /* + * We _should_ have TASK_RUNNING here, but just in case + * we do not, make it so, otherwise we might get stuck. + */ + __set_current_state(TASK_RUNNING); schedule_preempt_disabled(); + } return false; }