Commit 918fc0372831dca73039e1577bfea0c2ce49bdb6

Authored by Oleg Nesterov
Committed by Thomas Gleixner
1 parent 4aa7361179

posix-timers: always do get_task_struct(timer->it_process)

Change the code to get/put timer->it_process regardless of
SIGEV_THREAD_ID.  This streamlines the create/destroy paths and allows us
to simplify the usage of exit_itimers() in de_thread().

Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>
Cc: mingo@elte.hu
Cc: Roland McGrath <roland@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

Showing 1 changed file with 4 additions and 6 deletions Side-by-side Diff

kernel/posix-timers.c
... ... @@ -540,11 +540,10 @@
540 540 */
541 541 spin_lock_irqsave(&process->sighand->siglock, flags);
542 542 if (!(process->flags & PF_EXITING)) {
  543 + get_task_struct(process);
543 544 new_timer->it_process = process;
544 545 list_add(&new_timer->list,
545 546 &process->signal->posix_timers);
546   - if (new_timer->it_sigev_notify == (SIGEV_SIGNAL|SIGEV_THREAD_ID))
547   - get_task_struct(process);
548 547 spin_unlock_irqrestore(&process->sighand->siglock, flags);
549 548 } else {
550 549 spin_unlock_irqrestore(&process->sighand->siglock, flags);
... ... @@ -561,6 +560,7 @@
561 560 new_timer->it_sigev_signo = SIGALRM;
562 561 new_timer->it_sigev_value.sival_int = new_timer->it_id;
563 562 process = current->group_leader;
  563 + get_task_struct(process);
564 564 spin_lock_irqsave(&process->sighand->siglock, flags);
565 565 new_timer->it_process = process;
566 566 list_add(&new_timer->list, &process->signal->posix_timers);
... ... @@ -853,8 +853,7 @@
853 853 * This keeps any tasks waiting on the spin lock from thinking
854 854 * they got something (see the lock code above).
855 855 */
856   - if (timer->it_sigev_notify == (SIGEV_SIGNAL|SIGEV_THREAD_ID))
857   - put_task_struct(timer->it_process);
  856 + put_task_struct(timer->it_process);
858 857 timer->it_process = NULL;
859 858  
860 859 unlock_timer(timer, flags);
... ... @@ -881,8 +880,7 @@
881 880 * This keeps any tasks waiting on the spin lock from thinking
882 881 * they got something (see the lock code above).
883 882 */
884   - if (timer->it_sigev_notify == (SIGEV_SIGNAL|SIGEV_THREAD_ID))
885   - put_task_struct(timer->it_process);
  883 + put_task_struct(timer->it_process);
886 884 timer->it_process = NULL;
887 885  
888 886 unlock_timer(timer, flags);