]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
ipc, sem: prevent possible deadlock
authorDavidlohr Bueso <davidlohr.bueso@hp.com>
Tue, 26 Mar 2013 23:26:03 +0000 (10:26 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Thu, 4 Apr 2013 06:26:27 +0000 (17:26 +1100)
In semctl_main(), when cmd == GETALL, we're locking sma->sem_perm.lock
(through sem_lock_and_putref), yet after the conditional, we lock it
again.  Unlock sma right after exiting the conditional.

Signed-off-by: Davidlohr Bueso <davidlohr.bueso@hp.com>
Reviewed-by: Rik van Riel <riel@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
ipc/sem.c

index 0dcb73933c25b9dcafa4c288f0611d53a281294b..94b9a0ac60aa8291b013c1e39a97d5efb34917bd 100644 (file)
--- a/ipc/sem.c
+++ b/ipc/sem.c
@@ -1115,6 +1115,7 @@ static int semctl_main(struct ipc_namespace *ns, int semid, int semnum,
                                err = -EIDRM;
                                goto out_free;
                        }
+                       sem_unlock(sma, -1);
                }
 
                sem_lock(sma, NULL, -1);