aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/posix-cpu-timers.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/posix-cpu-timers.c')
-rw-r--r--kernel/posix-cpu-timers.c31
1 files changed, 14 insertions, 17 deletions
diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
index ad85d3f0dcc..b3f3edc475d 100644
--- a/kernel/posix-cpu-timers.c
+++ b/kernel/posix-cpu-timers.c
@@ -387,25 +387,19 @@ int posix_cpu_timer_del(struct k_itimer *timer)
387 if (unlikely(p == NULL)) 387 if (unlikely(p == NULL))
388 return 0; 388 return 0;
389 389
390 spin_lock(&p->sighand->siglock);
390 if (!list_empty(&timer->it.cpu.entry)) { 391 if (!list_empty(&timer->it.cpu.entry)) {
391 read_lock(&tasklist_lock); 392 /*
392 if (unlikely(p->signal == NULL)) { 393 * Take us off the task's timer list. We don't need to
393 /* 394 * take tasklist_lock and check for the task being reaped.
394 * We raced with the reaping of the task. 395 * If it was reaped, it already called posix_cpu_timers_exit
395 * The deletion should have cleared us off the list. 396 * and posix_cpu_timers_exit_group to clear all the timers
396 */ 397 * that pointed to it.
397 BUG_ON(!list_empty(&timer->it.cpu.entry)); 398 */
398 } else { 399 list_del(&timer->it.cpu.entry);
399 /* 400 put_task_struct(p);
400 * Take us off the task's timer list.
401 */
402 spin_lock(&p->sighand->siglock);
403 list_del(&timer->it.cpu.entry);
404 spin_unlock(&p->sighand->siglock);
405 }
406 read_unlock(&tasklist_lock);
407 } 401 }
408 put_task_struct(p); 402 spin_unlock(&p->sighand->siglock);
409 403
410 return 0; 404 return 0;
411} 405}
@@ -424,6 +418,7 @@ static void cleanup_timers(struct list_head *head,
424 cputime_t ptime = cputime_add(utime, stime); 418 cputime_t ptime = cputime_add(utime, stime);
425 419
426 list_for_each_entry_safe(timer, next, head, entry) { 420 list_for_each_entry_safe(timer, next, head, entry) {
421 put_task_struct(timer->task);
427 timer->task = NULL; 422 timer->task = NULL;
428 list_del_init(&timer->entry); 423 list_del_init(&timer->entry);
429 if (cputime_lt(timer->expires.cpu, ptime)) { 424 if (cputime_lt(timer->expires.cpu, ptime)) {
@@ -436,6 +431,7 @@ static void cleanup_timers(struct list_head *head,
436 431
437 ++head; 432 ++head;
438 list_for_each_entry_safe(timer, next, head, entry) { 433 list_for_each_entry_safe(timer, next, head, entry) {
434 put_task_struct(timer->task);
439 timer->task = NULL; 435 timer->task = NULL;
440 list_del_init(&timer->entry); 436 list_del_init(&timer->entry);
441 if (cputime_lt(timer->expires.cpu, utime)) { 437 if (cputime_lt(timer->expires.cpu, utime)) {
@@ -448,6 +444,7 @@ static void cleanup_timers(struct list_head *head,
448 444
449 ++head; 445 ++head;
450 list_for_each_entry_safe(timer, next, head, entry) { 446 list_for_each_entry_safe(timer, next, head, entry) {
447 put_task_struct(timer->task);
451 timer->task = NULL; 448 timer->task = NULL;
452 list_del_init(&timer->entry); 449 list_del_init(&timer->entry);
453 if (timer->expires.sched < sched_time) { 450 if (timer->expires.sched < sched_time) {