aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/fork.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/fork.c')
-rw-r--r--kernel/fork.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/kernel/fork.c b/kernel/fork.c
index e49f181ba1c..266c6af6ef1 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -518,6 +518,8 @@ void mmput(struct mm_struct *mm)
518 spin_unlock(&mmlist_lock); 518 spin_unlock(&mmlist_lock);
519 } 519 }
520 put_swap_token(mm); 520 put_swap_token(mm);
521 if (mm->binfmt)
522 module_put(mm->binfmt->module);
521 mmdrop(mm); 523 mmdrop(mm);
522 } 524 }
523} 525}
@@ -643,9 +645,14 @@ struct mm_struct *dup_mm(struct task_struct *tsk)
643 mm->hiwater_rss = get_mm_rss(mm); 645 mm->hiwater_rss = get_mm_rss(mm);
644 mm->hiwater_vm = mm->total_vm; 646 mm->hiwater_vm = mm->total_vm;
645 647
648 if (mm->binfmt && !try_module_get(mm->binfmt->module))
649 goto free_pt;
650
646 return mm; 651 return mm;
647 652
648free_pt: 653free_pt:
654 /* don't put binfmt in mmput, we haven't got module yet */
655 mm->binfmt = NULL;
649 mmput(mm); 656 mmput(mm);
650 657
651fail_nomem: 658fail_nomem:
@@ -1037,9 +1044,6 @@ static struct task_struct *copy_process(unsigned long clone_flags,
1037 if (!try_module_get(task_thread_info(p)->exec_domain->module)) 1044 if (!try_module_get(task_thread_info(p)->exec_domain->module))
1038 goto bad_fork_cleanup_count; 1045 goto bad_fork_cleanup_count;
1039 1046
1040 if (p->binfmt && !try_module_get(p->binfmt->module))
1041 goto bad_fork_cleanup_put_domain;
1042
1043 p->did_exec = 0; 1047 p->did_exec = 0;
1044 delayacct_tsk_init(p); /* Must remain after dup_task_struct() */ 1048 delayacct_tsk_init(p); /* Must remain after dup_task_struct() */
1045 copy_flags(clone_flags, p); 1049 copy_flags(clone_flags, p);
@@ -1327,9 +1331,6 @@ bad_fork_cleanup_cgroup:
1327#endif 1331#endif
1328 cgroup_exit(p, cgroup_callbacks_done); 1332 cgroup_exit(p, cgroup_callbacks_done);
1329 delayacct_tsk_free(p); 1333 delayacct_tsk_free(p);
1330 if (p->binfmt)
1331 module_put(p->binfmt->module);
1332bad_fork_cleanup_put_domain:
1333 module_put(task_thread_info(p)->exec_domain->module); 1334 module_put(task_thread_info(p)->exec_domain->module);
1334bad_fork_cleanup_count: 1335bad_fork_cleanup_count:
1335 atomic_dec(&p->cred->user->processes); 1336 atomic_dec(&p->cred->user->processes);