coredump: factor out put_cred() calls
Given that do_coredump() calls put_cred() on exit path, it is a bit ugly to do put_cred() + "goto fail" twice, just add the new "fail_creds" label. Signed-off-by: Oleg Nesterov <oleg@redhat.com> Cc: David Howells <dhowells@redhat.com> Cc: Neil Horman <nhorman@tuxdriver.com> Cc: Roland McGrath <roland@redhat.com> Cc: Andi Kleen <andi@firstfloor.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
d5bf4c4f5f
commit
5e43aef530
18
fs/exec.c
18
fs/exec.c
|
@ -1862,10 +1862,8 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
cred = prepare_creds();
|
cred = prepare_creds();
|
||||||
if (!cred) {
|
if (!cred)
|
||||||
retval = -ENOMEM;
|
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
|
||||||
|
|
||||||
down_write(&mm->mmap_sem);
|
down_write(&mm->mmap_sem);
|
||||||
/*
|
/*
|
||||||
|
@ -1873,8 +1871,7 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs)
|
||||||
*/
|
*/
|
||||||
if (mm->core_state || !__get_dumpable(cprm.mm_flags)) {
|
if (mm->core_state || !__get_dumpable(cprm.mm_flags)) {
|
||||||
up_write(&mm->mmap_sem);
|
up_write(&mm->mmap_sem);
|
||||||
put_cred(cred);
|
goto fail_creds;
|
||||||
goto fail;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1889,10 +1886,8 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs)
|
||||||
}
|
}
|
||||||
|
|
||||||
retval = coredump_wait(exit_code, &core_state);
|
retval = coredump_wait(exit_code, &core_state);
|
||||||
if (retval < 0) {
|
if (retval < 0)
|
||||||
put_cred(cred);
|
goto fail_creds;
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
|
|
||||||
old_cred = override_creds(cred);
|
old_cred = override_creds(cred);
|
||||||
|
|
||||||
|
@ -2009,9 +2004,10 @@ fail_dropcount:
|
||||||
if (ispipe)
|
if (ispipe)
|
||||||
atomic_dec(&core_dump_count);
|
atomic_dec(&core_dump_count);
|
||||||
fail_unlock:
|
fail_unlock:
|
||||||
revert_creds(old_cred);
|
|
||||||
put_cred(cred);
|
|
||||||
coredump_finish(mm);
|
coredump_finish(mm);
|
||||||
|
revert_creds(old_cred);
|
||||||
|
fail_creds:
|
||||||
|
put_cred(cred);
|
||||||
fail:
|
fail:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue