aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ipc/shm.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/ipc/shm.c b/ipc/shm.c
index 6d767071c367..bd9c91f433c1 100644
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -155,8 +155,11 @@ static inline struct shmid_kernel *shm_lock(struct ipc_namespace *ns, int id)
155{ 155{
156 struct kern_ipc_perm *ipcp = ipc_lock(&shm_ids(ns), id); 156 struct kern_ipc_perm *ipcp = ipc_lock(&shm_ids(ns), id);
157 157
158 if (IS_ERR(ipcp)) 158 /*
159 return (struct shmid_kernel *)ipcp; 159 * We raced in the idr lookup or with shm_destroy(). Either way, the
160 * ID is busted.
161 */
162 BUG_ON(IS_ERR(ipcp));
160 163
161 return container_of(ipcp, struct shmid_kernel, shm_perm); 164 return container_of(ipcp, struct shmid_kernel, shm_perm);
162} 165}
@@ -191,7 +194,6 @@ static void shm_open(struct vm_area_struct *vma)
191 struct shmid_kernel *shp; 194 struct shmid_kernel *shp;
192 195
193 shp = shm_lock(sfd->ns, sfd->id); 196 shp = shm_lock(sfd->ns, sfd->id);
194 BUG_ON(IS_ERR(shp));
195 shp->shm_atim = get_seconds(); 197 shp->shm_atim = get_seconds();
196 shp->shm_lprid = task_tgid_vnr(current); 198 shp->shm_lprid = task_tgid_vnr(current);
197 shp->shm_nattch++; 199 shp->shm_nattch++;
@@ -258,7 +260,6 @@ static void shm_close(struct vm_area_struct *vma)
258 down_write(&shm_ids(ns).rwsem); 260 down_write(&shm_ids(ns).rwsem);
259 /* remove from the list of attaches of the shm segment */ 261 /* remove from the list of attaches of the shm segment */
260 shp = shm_lock(ns, sfd->id); 262 shp = shm_lock(ns, sfd->id);
261 BUG_ON(IS_ERR(shp));
262 shp->shm_lprid = task_tgid_vnr(current); 263 shp->shm_lprid = task_tgid_vnr(current);
263 shp->shm_dtim = get_seconds(); 264 shp->shm_dtim = get_seconds();
264 shp->shm_nattch--; 265 shp->shm_nattch--;
@@ -1191,7 +1192,6 @@ out_fput:
1191out_nattch: 1192out_nattch:
1192 down_write(&shm_ids(ns).rwsem); 1193 down_write(&shm_ids(ns).rwsem);
1193 shp = shm_lock(ns, shmid); 1194 shp = shm_lock(ns, shmid);
1194 BUG_ON(IS_ERR(shp));
1195 shp->shm_nattch--; 1195 shp->shm_nattch--;
1196 if (shm_may_destroy(ns, shp)) 1196 if (shm_may_destroy(ns, shp))
1197 shm_destroy(ns, shp); 1197 shm_destroy(ns, shp);