提交 eaccbfa5 编写于 作者: L Luiz Fernando N. Capitulino 提交者: Linus Torvalds

fs/exec.c:__bprm_mm_init(): clean up error handling

Untangle the error unwinding in this function, saving a test of local
variable `vma'.
Signed-off-by: NLuiz Fernando N. Capitulino <lcapitulino@mandriva.com.br>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 bca1033b
...@@ -232,13 +232,13 @@ static void flush_arg_page(struct linux_binprm *bprm, unsigned long pos, ...@@ -232,13 +232,13 @@ static void flush_arg_page(struct linux_binprm *bprm, unsigned long pos,
static int __bprm_mm_init(struct linux_binprm *bprm) static int __bprm_mm_init(struct linux_binprm *bprm)
{ {
int err = -ENOMEM; int err;
struct vm_area_struct *vma = NULL; struct vm_area_struct *vma = NULL;
struct mm_struct *mm = bprm->mm; struct mm_struct *mm = bprm->mm;
bprm->vma = vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL); bprm->vma = vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
if (!vma) if (!vma)
goto err; return -ENOMEM;
down_write(&mm->mmap_sem); down_write(&mm->mmap_sem);
vma->vm_mm = mm; vma->vm_mm = mm;
...@@ -251,28 +251,20 @@ static int __bprm_mm_init(struct linux_binprm *bprm) ...@@ -251,28 +251,20 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
*/ */
vma->vm_end = STACK_TOP_MAX; vma->vm_end = STACK_TOP_MAX;
vma->vm_start = vma->vm_end - PAGE_SIZE; vma->vm_start = vma->vm_end - PAGE_SIZE;
vma->vm_flags = VM_STACK_FLAGS; vma->vm_flags = VM_STACK_FLAGS;
vma->vm_page_prot = vm_get_page_prot(vma->vm_flags); vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
err = insert_vm_struct(mm, vma); err = insert_vm_struct(mm, vma);
if (err) { if (err)
up_write(&mm->mmap_sem);
goto err; goto err;
}
mm->stack_vm = mm->total_vm = 1; mm->stack_vm = mm->total_vm = 1;
up_write(&mm->mmap_sem); up_write(&mm->mmap_sem);
bprm->p = vma->vm_end - sizeof(void *); bprm->p = vma->vm_end - sizeof(void *);
return 0; return 0;
err: err:
if (vma) { up_write(&mm->mmap_sem);
bprm->vma = NULL; bprm->vma = NULL;
kmem_cache_free(vm_area_cachep, vma); kmem_cache_free(vm_area_cachep, vma);
}
return err; return err;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册