vserver 1.9.5.x5
[linux-2.6.git] / arch / ia64 / ia32 / binfmt_elf32.c
index 093129c..3941e04 100644 (file)
@@ -35,7 +35,7 @@ extern void ia64_elf32_init (struct pt_regs *regs);
 
 static void elf32_set_personality (void);
 
-#define setup_arg_pages(bprm,exec)             ia32_setup_arg_pages(bprm,exec)
+#define setup_arg_pages(bprm,tos,exec)         ia32_setup_arg_pages(bprm,exec)
 #define elf_map                                elf32_map
 
 #undef SET_PERSONALITY
@@ -100,7 +100,11 @@ ia64_elf32_init (struct pt_regs *regs)
                vma->vm_ops = &ia32_shared_page_vm_ops;
                down_write(&current->mm->mmap_sem);
                {
-                       insert_vm_struct(current->mm, vma);
+                       if (insert_vm_struct(current->mm, vma)) {
+                               kmem_cache_free(vm_area_cachep, vma);
+                               up_write(&current->mm->mmap_sem);
+                               BUG();
+                       }
                }
                up_write(&current->mm->mmap_sem);
        }
@@ -123,7 +127,11 @@ ia64_elf32_init (struct pt_regs *regs)
                vma->vm_ops = &ia32_gate_page_vm_ops;
                down_write(&current->mm->mmap_sem);
                {
-                       insert_vm_struct(current->mm, vma);
+                       if (insert_vm_struct(current->mm, vma)) {
+                               kmem_cache_free(vm_area_cachep, vma);
+                               up_write(&current->mm->mmap_sem);
+                               BUG();
+                       }
                }
                up_write(&current->mm->mmap_sem);
        }
@@ -142,7 +150,11 @@ ia64_elf32_init (struct pt_regs *regs)
                vma->vm_flags = VM_READ|VM_WRITE|VM_MAYREAD|VM_MAYWRITE;
                down_write(&current->mm->mmap_sem);
                {
-                       insert_vm_struct(current->mm, vma);
+                       if (insert_vm_struct(current->mm, vma)) {
+                               kmem_cache_free(vm_area_cachep, vma);
+                               up_write(&current->mm->mmap_sem);
+                               BUG();
+                       }
                }
                up_write(&current->mm->mmap_sem);
        }
@@ -190,7 +202,7 @@ ia32_setup_arg_pages (struct linux_binprm *bprm, int executable_stack)
        unsigned long stack_base, grow;
        struct vm_area_struct *mpnt;
        struct mm_struct *mm = current->mm;
-       int i;
+       int i, ret;
 
        stack_base = IA32_STACK_TOP - MAX_ARG_PAGES*PAGE_SIZE;
        mm->arg_start = bprm->p + stack_base;
@@ -227,7 +239,11 @@ ia32_setup_arg_pages (struct linux_binprm *bprm, int executable_stack)
                        mpnt->vm_flags = VM_STACK_FLAGS;
                mpnt->vm_page_prot = (mpnt->vm_flags & VM_EXEC)?
                                        PAGE_COPY_EXEC: PAGE_COPY;
-               insert_vm_struct(current->mm, mpnt);
+               if ((ret = insert_vm_struct(current->mm, mpnt))) {
+                       up_write(&current->mm->mmap_sem);
+                       kmem_cache_free(vm_area_cachep, mpnt);
+                       return ret;
+               }
                // current->mm->stack_vm = current->mm->total_vm = vma_pages(mpnt);
                vx_vmpages_sub(current->mm, current->mm->total_vm - vma_pages(mpnt));
                current->mm->stack_vm = current->mm->total_vm;