lkml.org 
[lkml]   [2022]   [Mar]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] kernel/locking: Return proper value in __down_common()
Date
From: Teng Hu <huteng.ht@bytedance.com>

Return -ETIME when a process waiting on a semaphore woken up
due to timedout, while return -EINTR when woken up by a signal.

Signed-off-by: Teng Hu <huteng.ht@bytedance.com>
---
kernel/locking/semaphore.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/kernel/locking/semaphore.c b/kernel/locking/semaphore.c
index 9ee381e4d2a4..97ad6a747d2f 100644
--- a/kernel/locking/semaphore.c
+++ b/kernel/locking/semaphore.c
@@ -225,6 +225,8 @@ static inline int __sched __down_common(struct semaphore *sem, long state,
raw_spin_lock_irq(&sem->lock);
if (waiter.up)
return 0;
+ if (timeout)
+ goto interrupted;
}

timed_out:
--
2.20.1
\
 
 \ /
  Last update: 2022-09-17 16:16    [W:0.048 / U:0.888 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site