From 53d1ac83407b1e56582710c493163b49fd071f45 Mon Sep 17 00:00:00 2001 From: Nick Piggin Date: Tue, 15 Dec 2009 16:47:28 -0800 Subject: [PATCH] --- yaml --- r: 176690 b: refs/heads/master c: bf17bb717759d50a2733a7a8157a7c4a25d93abc h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/ipc/sem.c | 26 ++++++++++++++++++++------ 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/[refs] b/[refs] index f157ece44a6f..50e7e0492b21 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 7d6feeb287c61aafa88f06345387b1188edf4b86 +refs/heads/master: bf17bb717759d50a2733a7a8157a7c4a25d93abc diff --git a/trunk/ipc/sem.c b/trunk/ipc/sem.c index 2f2a47959576..cb0070ecf5bf 100644 --- a/trunk/ipc/sem.c +++ b/trunk/ipc/sem.c @@ -962,17 +962,31 @@ static inline int get_undo_list(struct sem_undo_list **undo_listp) return 0; } -static struct sem_undo *lookup_undo(struct sem_undo_list *ulp, int semid) +static struct sem_undo *__lookup_undo(struct sem_undo_list *ulp, int semid) { - struct sem_undo *walk; + struct sem_undo *un; - list_for_each_entry_rcu(walk, &ulp->list_proc, list_proc) { - if (walk->semid == semid) - return walk; + list_for_each_entry_rcu(un, &ulp->list_proc, list_proc) { + if (un->semid == semid) + return un; } return NULL; } +static struct sem_undo *lookup_undo(struct sem_undo_list *ulp, int semid) +{ + struct sem_undo *un; + + assert_spin_locked(&ulp->lock); + + un = __lookup_undo(ulp, semid); + if (un) { + list_del_rcu(&un->list_proc); + list_add_rcu(&un->list_proc, &ulp->list_proc); + } + return un; +} + /** * find_alloc_undo - Lookup (and if not present create) undo array * @ns: namespace @@ -1308,7 +1322,7 @@ void exit_sem(struct task_struct *tsk) if (IS_ERR(sma)) continue; - un = lookup_undo(ulp, semid); + un = __lookup_undo(ulp, semid); if (un == NULL) { /* exit_sem raced with IPC_RMID+semget() that created * exactly the same semid. Nothing to do.