patch-2.2.16 linux/ipc/shm.c
Next file: linux/kernel/capability.c
Previous file: linux/init/main.c
Back to the patch index
Back to the overall index
- Lines: 30
- Date:
Wed Jun 7 14:26:44 2000
- Orig file:
v2.2.15/linux/ipc/shm.c
- Orig date:
Wed May 3 17:16:53 2000
diff -urN v2.2.15/linux/ipc/shm.c linux/ipc/shm.c
@@ -12,6 +12,7 @@
#include <linux/smp_lock.h>
#include <linux/init.h>
#include <linux/vmalloc.h>
+#include <linux/tasks.h>
#include <asm/uaccess.h>
#include <asm/pgtable.h>
@@ -517,7 +518,7 @@
shmd->vm_ops = &shm_vm_ops;
shp->u.shm_nattch++; /* prevent destruction */
- if ((err = shm_map (shmd))) {
+ if (shp->u.shm_nattch > 0xffff - NR_TASKS || (err = shm_map (shmd))) {
if (--shp->u.shm_nattch <= 0 && shp->u.shm_perm.mode & SHM_DEST)
killseg(id);
kmem_cache_free(vm_area_cachep, shmd);
@@ -549,8 +550,11 @@
printk("shm_open: unused id=%d PANIC\n", id);
return;
}
+ if (!++shp->u.shm_nattch) {
+ shp->u.shm_nattch--;
+ return; /* XXX: should be able to report failure */
+ }
insert_attach(shp,shmd); /* insert shmd into shp->attaches */
- shp->u.shm_nattch++;
shp->u.shm_atime = CURRENT_TIME;
shp->u.shm_lpid = current->pid;
}
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)