Merge remote-tracking branches 'asoc/topic/max98090', 'asoc/topic/max98095', 'asoc...
[firefly-linux-kernel-4.4.55.git] / ipc / util.c
index 3fdfabfdd9c318f9410dd105b91f014e4f15a93d..be4230020a1f718c31b02012554600c710b928b9 100644 (file)
@@ -583,19 +583,22 @@ struct kern_ipc_perm *ipc_lock(struct ipc_ids *ids, int id)
        rcu_read_lock();
        out = ipc_obtain_object_idr(ids, id);
        if (IS_ERR(out))
-               goto err1;
+               goto err;
 
        spin_lock(&out->lock);
 
-       /* ipc_rmid() may have already freed the ID while ipc_lock
-        * was spinning: here verify that the structure is still valid
+       /*
+        * ipc_rmid() may have already freed the ID while ipc_lock()
+        * was spinning: here verify that the structure is still valid.
+        * Upon races with RMID, return -EIDRM, thus indicating that
+        * the ID points to a removed identifier.
         */
        if (ipc_valid_object(out))
                return out;
 
        spin_unlock(&out->lock);
-       out = ERR_PTR(-EINVAL);
-err1:
+       out = ERR_PTR(-EIDRM);
+err:
        rcu_read_unlock();
        return out;
 }
@@ -619,7 +622,7 @@ struct kern_ipc_perm *ipc_obtain_object_check(struct ipc_ids *ids, int id)
                goto out;
 
        if (ipc_checkid(out, id))
-               return ERR_PTR(-EIDRM);
+               return ERR_PTR(-EINVAL);
 out:
        return out;
 }