]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
ipc-introduce-obtaining-a-lockless-ipc-object-fix
authorAndrew Morton <akpm@linux-foundation.org>
Sat, 23 Mar 2013 02:32:54 +0000 (13:32 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Tue, 26 Mar 2013 05:11:37 +0000 (16:11 +1100)
propagate the ipc_obtain_object() errno from ipc_lock()

Cc: Chegu Vinod <chegu_vinod@hp.com>
Cc: Davidlohr Bueso <davidlohr.bueso@hp.com>
Cc: Emmanuel Benisty <benisty.e@gmail.com>
Cc: Jason Low <jason.low2@hp.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Michel Lespinasse <walken@google.com>
Cc: Peter Hurley <peter@hurleysoftware.com>
Cc: Rik van Riel <riel@redhat.com>
Cc: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
ipc/util.c

index eb4e587ba0ec3114ab8e1d42f49b1836cfe7b352..340461eb60e6819deff16cc227ab1406d0bdf829 100644 (file)
@@ -696,9 +696,8 @@ struct kern_ipc_perm *ipc_obtain_object(struct ipc_ids *ids, int id)
  *
  * Look for an id in the ipc ids idr and lock the associated ipc object.
  *
- * The ipc object is locked on exit.
+ * The ipc object is locked on successful exit.
  */
-
 struct kern_ipc_perm *ipc_lock(struct ipc_ids *ids, int id)
 {
        struct kern_ipc_perm *out;
@@ -713,15 +712,14 @@ struct kern_ipc_perm *ipc_lock(struct ipc_ids *ids, int id)
        /* ipc_rmid() may have already freed the ID while ipc_lock
         * was spinning: here verify that the structure is still valid
         */
-       if (out->deleted)
-               goto err0;
+       if (!out->deleted)
+               return out;
 
-       return out;
-err0:
        spin_unlock(&out->lock);
+       out = ERR_PTR(-EINVAL);
 err1:
        rcu_read_unlock();
-       return ERR_PTR(-EINVAL);
+       return out;
 }
 
 /**