patch-2.4.19 linux-2.4.19/ipc/shm.c
Next file: linux-2.4.19/kernel/acct.c
Previous file: linux-2.4.19/ipc/sem.c
Back to the patch index
Back to the overall index
- Lines: 72
- Date:
Fri Aug 2 17:39:46 2002
- Orig file:
linux-2.4.18/ipc/shm.c
- Orig date:
Fri Dec 21 09:42:04 2001
diff -urN linux-2.4.18/ipc/shm.c linux-2.4.19/ipc/shm.c
@@ -117,12 +117,14 @@
*
* @shp: struct to free
*
- * It has to be called with shp and shm_ids.sem locked
+ * It has to be called with shp and shm_ids.sem locked,
+ * but returns with shp unlocked and freed.
*/
static void shm_destroy (struct shmid_kernel *shp)
{
shm_tot -= (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
shm_rmid (shp->id);
+ shm_unlock(shp->id);
shmem_lock(shp->shm_file, 0);
fput (shp->shm_file);
kfree (shp);
@@ -150,8 +152,8 @@
if(shp->shm_nattch == 0 &&
shp->shm_flags & SHM_DEST)
shm_destroy (shp);
-
- shm_unlock(id);
+ else
+ shm_unlock(id);
up (&shm_ids.sem);
}
@@ -511,11 +513,9 @@
shp->shm_flags |= SHM_DEST;
/* Do not find it any more */
shp->shm_perm.key = IPC_PRIVATE;
+ shm_unlock(shmid);
} else
shm_destroy (shp);
-
- /* Unlock */
- shm_unlock(shmid);
up(&shm_ids.sem);
return err;
}
@@ -653,7 +653,8 @@
if(shp->shm_nattch == 0 &&
shp->shm_flags & SHM_DEST)
shm_destroy (shp);
- shm_unlock(shmid);
+ else
+ shm_unlock(shmid);
up (&shm_ids.sem);
*raddr = (unsigned long) user_addr;
@@ -672,16 +673,19 @@
{
struct mm_struct *mm = current->mm;
struct vm_area_struct *shmd, *shmdnext;
+ int retval = -EINVAL;
down_write(&mm->mmap_sem);
for (shmd = mm->mmap; shmd; shmd = shmdnext) {
shmdnext = shmd->vm_next;
if (shmd->vm_ops == &shm_vm_ops
- && shmd->vm_start - (shmd->vm_pgoff << PAGE_SHIFT) == (ulong) shmaddr)
+ && shmd->vm_start - (shmd->vm_pgoff << PAGE_SHIFT) == (ulong) shmaddr) {
do_munmap(mm, shmd->vm_start, shmd->vm_end - shmd->vm_start);
+ retval = 0;
+ }
}
up_write(&mm->mmap_sem);
- return 0;
+ return retval;
}
#ifdef CONFIG_PROC_FS
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)