[PATCH V2 2/4] posix-timers: Initialise timer->it_id in posix_timer_add()
From: Eric Dumazet
Date: Wed Feb 19 2025 - 07:59:48 EST
A timer is visible only when both timer->signal and timer->i_id
are set to their final values.
We can initialize timer->it_id sooner.
Signed-off-by: Eric Dumazet <edumazet@xxxxxxxxxx>
---
kernel/time/posix-timers.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c
index 204a351a2fd3..1f73ea955756 100644
--- a/kernel/time/posix-timers.c
+++ b/kernel/time/posix-timers.c
@@ -114,6 +114,7 @@ static int posix_timer_add(struct k_itimer *timer)
spin_lock(&hash_lock);
if (!__posix_timers_find(head, sig, id)) {
+ timer->it_id = (timer_t)id;
hlist_add_head_rcu(&timer->t_hash, head);
spin_unlock(&hash_lock);
return id;
@@ -407,8 +408,7 @@ static int do_timer_create(clockid_t which_clock, struct sigevent *event,
/*
* Add the timer to the hash table. The timer is not yet valid
- * because new_timer::it_signal is still NULL. The timer id is also
- * not yet visible to user space.
+ * because new_timer::it_signal is still NULL.
*/
new_timer_id = posix_timer_add(new_timer);
if (new_timer_id < 0) {
@@ -416,7 +416,6 @@ static int do_timer_create(clockid_t which_clock, struct sigevent *event,
return new_timer_id;
}
- new_timer->it_id = (timer_t) new_timer_id;
new_timer->it_clock = which_clock;
new_timer->kclock = kc;
new_timer->it_overrun = -1LL;
--
2.48.1.601.g30ceb7b040-goog