diff options
author | Luiz Fernando N. Capitulino <lcapitulino@mandriva.com.br> | 2009-01-06 17:40:44 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-01-06 18:59:11 -0500 |
commit | eaccbfa564e48c87626594511f42dc8c0ad2daae (patch) | |
tree | 9a23430bf4f82d4f3d26c9314d0149b14d0fab70 | |
parent | bca1033b092a6fab2ed00036e8a7f6e2df5d99a2 (diff) |
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: Luiz Fernando N. Capitulino <lcapitulino@mandriva.com.br>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | fs/exec.c | 20 |
1 files changed, 6 insertions, 14 deletions
@@ -232,13 +232,13 @@ static void flush_arg_page(struct linux_binprm *bprm, unsigned long pos, | |||
232 | 232 | ||
233 | static int __bprm_mm_init(struct linux_binprm *bprm) | 233 | static int __bprm_mm_init(struct linux_binprm *bprm) |
234 | { | 234 | { |
235 | int err = -ENOMEM; | 235 | int err; |
236 | struct vm_area_struct *vma = NULL; | 236 | struct vm_area_struct *vma = NULL; |
237 | struct mm_struct *mm = bprm->mm; | 237 | struct mm_struct *mm = bprm->mm; |
238 | 238 | ||
239 | bprm->vma = vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL); | 239 | bprm->vma = vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL); |
240 | if (!vma) | 240 | if (!vma) |
241 | goto err; | 241 | return -ENOMEM; |
242 | 242 | ||
243 | down_write(&mm->mmap_sem); | 243 | down_write(&mm->mmap_sem); |
244 | vma->vm_mm = mm; | 244 | vma->vm_mm = mm; |
@@ -251,28 +251,20 @@ static int __bprm_mm_init(struct linux_binprm *bprm) | |||
251 | */ | 251 | */ |
252 | vma->vm_end = STACK_TOP_MAX; | 252 | vma->vm_end = STACK_TOP_MAX; |
253 | vma->vm_start = vma->vm_end - PAGE_SIZE; | 253 | vma->vm_start = vma->vm_end - PAGE_SIZE; |
254 | |||
255 | vma->vm_flags = VM_STACK_FLAGS; | 254 | vma->vm_flags = VM_STACK_FLAGS; |
256 | vma->vm_page_prot = vm_get_page_prot(vma->vm_flags); | 255 | vma->vm_page_prot = vm_get_page_prot(vma->vm_flags); |
257 | err = insert_vm_struct(mm, vma); | 256 | err = insert_vm_struct(mm, vma); |
258 | if (err) { | 257 | if (err) |
259 | up_write(&mm->mmap_sem); | ||
260 | goto err; | 258 | goto err; |
261 | } | ||
262 | 259 | ||
263 | mm->stack_vm = mm->total_vm = 1; | 260 | mm->stack_vm = mm->total_vm = 1; |
264 | up_write(&mm->mmap_sem); | 261 | up_write(&mm->mmap_sem); |
265 | |||
266 | bprm->p = vma->vm_end - sizeof(void *); | 262 | bprm->p = vma->vm_end - sizeof(void *); |
267 | |||
268 | return 0; | 263 | return 0; |
269 | |||
270 | err: | 264 | err: |
271 | if (vma) { | 265 | up_write(&mm->mmap_sem); |
272 | bprm->vma = NULL; | 266 | bprm->vma = NULL; |
273 | kmem_cache_free(vm_area_cachep, vma); | 267 | kmem_cache_free(vm_area_cachep, vma); |
274 | } | ||
275 | |||
276 | return err; | 268 | return err; |
277 | } | 269 | } |
278 | 270 | ||