aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
Diffstat (limited to 'fs')
-rw-r--r--fs/exec.c20
1 files changed, 6 insertions, 14 deletions
diff --git a/fs/exec.c b/fs/exec.c
index 9c33f542dc77..6ca4e3d22a3d 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -232,13 +232,13 @@ static void flush_arg_page(struct linux_binprm *bprm, unsigned long pos,
232 232
233static int __bprm_mm_init(struct linux_binprm *bprm) 233static 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
270err: 264err:
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