ipc: simplify rcu_read_lock() in semctl_nolock()
authorLinus Torvalds <torvalds@linux-foundation.org>
Sat, 4 May 2013 18:04:29 +0000 (11:04 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sun, 5 May 2013 00:24:59 +0000 (17:24 -0700)
This trivially combines two rcu_read_lock() calls in both sides of a
if-statement into one single one in front of the if-statement.

Split out as an independent cleanup from the previous commit.

Acked-by: Davidlohr Bueso <davidlohr.bueso@hp.com>
Cc: Rik van Riel <riel@redhat.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
ipc/sem.c

index f2151babd26a7688ccc638b7a4dd35dd6022e5bb..899b598b63be30bb70f1182edb2b9b91a5e50bd9 100644 (file)
--- a/ipc/sem.c
+++ b/ipc/sem.c
@@ -948,8 +948,8 @@ static int semctl_nolock(struct ipc_namespace *ns, int semid,
 
                memset(&tbuf, 0, sizeof(tbuf));
 
+               rcu_read_lock();
                if (cmd == SEM_STAT) {
-                       rcu_read_lock();
                        sma = sem_obtain_object(ns, semid);
                        if (IS_ERR(sma)) {
                                err = PTR_ERR(sma);
@@ -957,7 +957,6 @@ static int semctl_nolock(struct ipc_namespace *ns, int semid,
                        }
                        id = sma->sem_perm.id;
                } else {
-                       rcu_read_lock();
                        sma = sem_obtain_object_check(ns, semid);
                        if (IS_ERR(sma)) {
                                err = PTR_ERR(sma);