aboutsummaryrefslogtreecommitdiffstats
path: root/ipc/sem.c
diff options
context:
space:
mode:
Diffstat (limited to 'ipc/sem.c')
-rw-r--r--ipc/sem.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/ipc/sem.c b/ipc/sem.c
index 35952c0bae46..d65e285b7e30 100644
--- a/ipc/sem.c
+++ b/ipc/sem.c
@@ -143,6 +143,7 @@ int sem_init_ns(struct ipc_namespace *ns)
143void sem_exit_ns(struct ipc_namespace *ns) 143void sem_exit_ns(struct ipc_namespace *ns)
144{ 144{
145 struct sem_array *sma; 145 struct sem_array *sma;
146 struct kern_ipc_perm *perm;
146 int next_id; 147 int next_id;
147 int total, in_use; 148 int total, in_use;
148 149
@@ -151,10 +152,11 @@ void sem_exit_ns(struct ipc_namespace *ns)
151 in_use = sem_ids(ns).in_use; 152 in_use = sem_ids(ns).in_use;
152 153
153 for (total = 0, next_id = 0; total < in_use; next_id++) { 154 for (total = 0, next_id = 0; total < in_use; next_id++) {
154 sma = idr_find(&sem_ids(ns).ipcs_idr, next_id); 155 perm = idr_find(&sem_ids(ns).ipcs_idr, next_id);
155 if (sma == NULL) 156 if (perm == NULL)
156 continue; 157 continue;
157 ipc_lock_by_ptr(&sma->sem_perm); 158 ipc_lock_by_ptr(perm);
159 sma = container_of(perm, struct sem_array, sem_perm);
158 freeary(ns, sma); 160 freeary(ns, sma);
159 total++; 161 total++;
160 } 162 }
@@ -181,6 +183,9 @@ static inline struct sem_array *sem_lock_check_down(struct ipc_namespace *ns,
181{ 183{
182 struct kern_ipc_perm *ipcp = ipc_lock_check_down(&sem_ids(ns), id); 184 struct kern_ipc_perm *ipcp = ipc_lock_check_down(&sem_ids(ns), id);
183 185
186 if (IS_ERR(ipcp))
187 return (struct sem_array *)ipcp;
188
184 return container_of(ipcp, struct sem_array, sem_perm); 189 return container_of(ipcp, struct sem_array, sem_perm);
185} 190}
186 191
@@ -192,6 +197,9 @@ static inline struct sem_array *sem_lock(struct ipc_namespace *ns, int id)
192{ 197{
193 struct kern_ipc_perm *ipcp = ipc_lock(&sem_ids(ns), id); 198 struct kern_ipc_perm *ipcp = ipc_lock(&sem_ids(ns), id);
194 199
200 if (IS_ERR(ipcp))
201 return (struct sem_array *)ipcp;
202
195 return container_of(ipcp, struct sem_array, sem_perm); 203 return container_of(ipcp, struct sem_array, sem_perm);
196} 204}
197 205
@@ -200,6 +208,9 @@ static inline struct sem_array *sem_lock_check(struct ipc_namespace *ns,
200{ 208{
201 struct kern_ipc_perm *ipcp = ipc_lock_check(&sem_ids(ns), id); 209 struct kern_ipc_perm *ipcp = ipc_lock_check(&sem_ids(ns), id);
202 210
211 if (IS_ERR(ipcp))
212 return (struct sem_array *)ipcp;
213
203 return container_of(ipcp, struct sem_array, sem_perm); 214 return container_of(ipcp, struct sem_array, sem_perm);
204} 215}
205 216