aboutsummaryrefslogtreecommitdiffstats
path: root/ipc/shm.c
diff options
context:
space:
mode:
Diffstat (limited to 'ipc/shm.c')
-rw-r--r--ipc/shm.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/ipc/shm.c b/ipc/shm.c
index 3818fae625c5..65c3a294aba5 100644
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -111,6 +111,7 @@ int shm_init_ns(struct ipc_namespace *ns)
111void shm_exit_ns(struct ipc_namespace *ns) 111void shm_exit_ns(struct ipc_namespace *ns)
112{ 112{
113 struct shmid_kernel *shp; 113 struct shmid_kernel *shp;
114 struct kern_ipc_perm *perm;
114 int next_id; 115 int next_id;
115 int total, in_use; 116 int total, in_use;
116 117
@@ -119,10 +120,11 @@ void shm_exit_ns(struct ipc_namespace *ns)
119 in_use = shm_ids(ns).in_use; 120 in_use = shm_ids(ns).in_use;
120 121
121 for (total = 0, next_id = 0; total < in_use; next_id++) { 122 for (total = 0, next_id = 0; total < in_use; next_id++) {
122 shp = idr_find(&shm_ids(ns).ipcs_idr, next_id); 123 perm = idr_find(&shm_ids(ns).ipcs_idr, next_id);
123 if (shp == NULL) 124 if (perm == NULL)
124 continue; 125 continue;
125 ipc_lock_by_ptr(&shp->shm_perm); 126 ipc_lock_by_ptr(perm);
127 shp = container_of(perm, struct shmid_kernel, shm_perm);
126 do_shm_rmid(ns, shp); 128 do_shm_rmid(ns, shp);
127 total++; 129 total++;
128 } 130 }
@@ -149,6 +151,9 @@ static inline struct shmid_kernel *shm_lock_down(struct ipc_namespace *ns,
149{ 151{
150 struct kern_ipc_perm *ipcp = ipc_lock_down(&shm_ids(ns), id); 152 struct kern_ipc_perm *ipcp = ipc_lock_down(&shm_ids(ns), id);
151 153
154 if (IS_ERR(ipcp))
155 return (struct shmid_kernel *)ipcp;
156
152 return container_of(ipcp, struct shmid_kernel, shm_perm); 157 return container_of(ipcp, struct shmid_kernel, shm_perm);
153} 158}
154 159
@@ -158,6 +163,9 @@ static inline struct shmid_kernel *shm_lock_check_down(
158{ 163{
159 struct kern_ipc_perm *ipcp = ipc_lock_check_down(&shm_ids(ns), id); 164 struct kern_ipc_perm *ipcp = ipc_lock_check_down(&shm_ids(ns), id);
160 165
166 if (IS_ERR(ipcp))
167 return (struct shmid_kernel *)ipcp;
168
161 return container_of(ipcp, struct shmid_kernel, shm_perm); 169 return container_of(ipcp, struct shmid_kernel, shm_perm);
162} 170}
163 171
@@ -169,6 +177,9 @@ static inline struct shmid_kernel *shm_lock(struct ipc_namespace *ns, int id)
169{ 177{
170 struct kern_ipc_perm *ipcp = ipc_lock(&shm_ids(ns), id); 178 struct kern_ipc_perm *ipcp = ipc_lock(&shm_ids(ns), id);
171 179
180 if (IS_ERR(ipcp))
181 return (struct shmid_kernel *)ipcp;
182
172 return container_of(ipcp, struct shmid_kernel, shm_perm); 183 return container_of(ipcp, struct shmid_kernel, shm_perm);
173} 184}
174 185
@@ -177,6 +188,9 @@ static inline struct shmid_kernel *shm_lock_check(struct ipc_namespace *ns,
177{ 188{
178 struct kern_ipc_perm *ipcp = ipc_lock_check(&shm_ids(ns), id); 189 struct kern_ipc_perm *ipcp = ipc_lock_check(&shm_ids(ns), id);
179 190
191 if (IS_ERR(ipcp))
192 return (struct shmid_kernel *)ipcp;
193
180 return container_of(ipcp, struct shmid_kernel, shm_perm); 194 return container_of(ipcp, struct shmid_kernel, shm_perm);
181} 195}
182 196