Skip to content

Commit

Permalink
ipc,sem: remove uneeded sem_undo_list lock usage in exit_sem()
Browse files Browse the repository at this point in the history
After we acquire the sma->sem_perm lock in exit_sem(), we are protected
against a racing IPC_RMID operation.  Also at that point, we are the last
user of sem_undo_list.  Therefore it isn't required that we acquire or use
ulp->lock.

Signed-off-by: Herton R. Krzesinski <[email protected]>
Acked-by: Manfred Spraul <[email protected]>
Cc: Davidlohr Bueso <[email protected]>
Cc: Rafael Aquini <[email protected]>
CC: Aristeu Rozanski <[email protected]>
Cc: David Jeffery <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Herton R. Krzesinski authored and torvalds committed Aug 14, 2015
1 parent 602b859 commit a979558
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions ipc/sem.c
Original file line number Diff line number Diff line change
Expand Up @@ -2123,9 +2123,11 @@ void exit_sem(struct task_struct *tsk)
ipc_assert_locked_object(&sma->sem_perm);
list_del(&un->list_id);

spin_lock(&ulp->lock);
/* we are the last process using this ulp, acquiring ulp->lock
* isn't required. Besides that, we are also protected against
* IPC_RMID as we hold sma->sem_perm lock now
*/
list_del_rcu(&un->list_proc);
spin_unlock(&ulp->lock);

/* perform adjustments registered in un */
for (i = 0; i < sma->sem_nsems; i++) {
Expand Down

0 comments on commit a979558

Please sign in to comment.