aboutsummaryrefslogtreecommitdiffstats
path: root/ipc/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'ipc/util.c')
-rw-r--r--ipc/util.c52
1 files changed, 1 insertions, 51 deletions
diff --git a/ipc/util.c b/ipc/util.c
index 0f468c34e83c..49b3ea615dc5 100644
--- a/ipc/util.c
+++ b/ipc/util.c
@@ -716,56 +716,6 @@ struct kern_ipc_perm *ipc_lock(struct ipc_ids *ids, int id)
716 return out; 716 return out;
717} 717}
718 718
719/**
720 * ipc_lock_down - Lock an ipc structure with rw_sem held
721 * @ids: IPC identifier set
722 * @id: ipc id to look for
723 *
724 * Look for an id in the ipc ids idr and lock the associated ipc object.
725 *
726 * The ipc object is locked on exit.
727 *
728 * This is the routine that should be called when the rw_mutex is already
729 * held, i.e. idr tree protected.
730 */
731
732struct kern_ipc_perm *ipc_lock_down(struct ipc_ids *ids, int id)
733{
734 struct kern_ipc_perm *out;
735 int lid = ipcid_to_idx(id);
736
737 rcu_read_lock();
738 out = idr_find(&ids->ipcs_idr, lid);
739 if (out == NULL) {
740 rcu_read_unlock();
741 return ERR_PTR(-EINVAL);
742 }
743
744 spin_lock(&out->lock);
745
746 /*
747 * No need to verify that the structure is still valid since the
748 * rw_mutex is held.
749 */
750 return out;
751}
752
753struct kern_ipc_perm *ipc_lock_check_down(struct ipc_ids *ids, int id)
754{
755 struct kern_ipc_perm *out;
756
757 out = ipc_lock_down(ids, id);
758 if (IS_ERR(out))
759 return out;
760
761 if (ipc_checkid(out, id)) {
762 ipc_unlock(out);
763 return ERR_PTR(-EIDRM);
764 }
765
766 return out;
767}
768
769struct kern_ipc_perm *ipc_lock_check(struct ipc_ids *ids, int id) 719struct kern_ipc_perm *ipc_lock_check(struct ipc_ids *ids, int id)
770{ 720{
771 struct kern_ipc_perm *out; 721 struct kern_ipc_perm *out;
@@ -837,7 +787,7 @@ struct kern_ipc_perm *ipcctl_pre_down(struct ipc_ids *ids, int id, int cmd,
837 int err; 787 int err;
838 788
839 down_write(&ids->rw_mutex); 789 down_write(&ids->rw_mutex);
840 ipcp = ipc_lock_check_down(ids, id); 790 ipcp = ipc_lock_check(ids, id);
841 if (IS_ERR(ipcp)) { 791 if (IS_ERR(ipcp)) {
842 err = PTR_ERR(ipcp); 792 err = PTR_ERR(ipcp);
843 goto out_up; 793 goto out_up;