summaryrefslogtreecommitdiff
path: root/fs/exec.c
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@redhat.com>2010-05-26 14:43:07 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2010-05-27 09:12:45 -0700
commit5e43aef530ba39206f7923295388f7ec3c5a7d93 (patch)
treeb29b706cff64eb47cc881a793566e38a511843f1 /fs/exec.c
parentd5bf4c4f5f9dcc90b7e25dbb2f7c4436cf6e7ed0 (diff)
downloadlinux-3.10-5e43aef530ba39206f7923295388f7ec3c5a7d93.tar.gz
linux-3.10-5e43aef530ba39206f7923295388f7ec3c5a7d93.tar.bz2
linux-3.10-5e43aef530ba39206f7923295388f7ec3c5a7d93.zip
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>
Diffstat (limited to 'fs/exec.c')
-rw-r--r--fs/exec.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/fs/exec.c b/fs/exec.c
index 1221c4c4354..6501823b7a1 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1862,10 +1862,8 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs)
goto fail;
cred = prepare_creds();
- if (!cred) {
- retval = -ENOMEM;
+ if (!cred)
goto fail;
- }
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)) {
up_write(&mm->mmap_sem);
- put_cred(cred);
- goto fail;
+ goto fail_creds;
}
/*
@@ -1889,10 +1886,8 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs)
}
retval = coredump_wait(exit_code, &core_state);
- if (retval < 0) {
- put_cred(cred);
- goto fail;
- }
+ if (retval < 0)
+ goto fail_creds;
old_cred = override_creds(cred);
@@ -2009,9 +2004,10 @@ fail_dropcount:
if (ispipe)
atomic_dec(&core_dump_count);
fail_unlock:
+ coredump_finish(mm);
revert_creds(old_cred);
+fail_creds:
put_cred(cred);
- coredump_finish(mm);
fail:
return;
}