aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ipc/shm.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/ipc/shm.c b/ipc/shm.c
index c6b4ad5ce3b7..216ae727a936 100644
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -124,6 +124,26 @@ void __init shm_init (void)
124 IPC_SHM_IDS, sysvipc_shm_proc_show); 124 IPC_SHM_IDS, sysvipc_shm_proc_show);
125} 125}
126 126
127static inline struct shmid_kernel *shm_obtain_object(struct ipc_namespace *ns, int id)
128{
129 struct kern_ipc_perm *ipcp = ipc_obtain_object(&shm_ids(ns), id);
130
131 if (IS_ERR(ipcp))
132 return ERR_CAST(ipcp);
133
134 return container_of(ipcp, struct shmid_kernel, shm_perm);
135}
136
137static inline struct shmid_kernel *shm_obtain_object_check(struct ipc_namespace *ns, int id)
138{
139 struct kern_ipc_perm *ipcp = ipc_obtain_object_check(&shm_ids(ns), id);
140
141 if (IS_ERR(ipcp))
142 return ERR_CAST(ipcp);
143
144 return container_of(ipcp, struct shmid_kernel, shm_perm);
145}
146
127/* 147/*
128 * shm_lock_(check_) routines are called in the paths where the rw_mutex 148 * shm_lock_(check_) routines are called in the paths where the rw_mutex
129 * is not necessarily held. 149 * is not necessarily held.