diff options
author | Oleg Nesterov <oleg@redhat.com> | 2010-05-26 17:43:07 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-05-27 12:12:45 -0400 |
commit | 5e43aef530ba39206f7923295388f7ec3c5a7d93 (patch) | |
tree | b29b706cff64eb47cc881a793566e38a511843f1 /fs/exec.c | |
parent | d5bf4c4f5f9dcc90b7e25dbb2f7c4436cf6e7ed0 (diff) |
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.c | 16 |
1 files changed, 6 insertions, 10 deletions
@@ -1862,10 +1862,8 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs) | |||
1862 | goto fail; | 1862 | goto fail; |
1863 | 1863 | ||
1864 | cred = prepare_creds(); | 1864 | cred = prepare_creds(); |
1865 | if (!cred) { | 1865 | if (!cred) |
1866 | retval = -ENOMEM; | ||
1867 | goto fail; | 1866 | goto fail; |
1868 | } | ||
1869 | 1867 | ||
1870 | down_write(&mm->mmap_sem); | 1868 | down_write(&mm->mmap_sem); |
1871 | /* | 1869 | /* |
@@ -1873,8 +1871,7 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs) | |||
1873 | */ | 1871 | */ |
1874 | if (mm->core_state || !__get_dumpable(cprm.mm_flags)) { | 1872 | if (mm->core_state || !__get_dumpable(cprm.mm_flags)) { |
1875 | up_write(&mm->mmap_sem); | 1873 | up_write(&mm->mmap_sem); |
1876 | put_cred(cred); | 1874 | goto fail_creds; |
1877 | goto fail; | ||
1878 | } | 1875 | } |
1879 | 1876 | ||
1880 | /* | 1877 | /* |
@@ -1889,10 +1886,8 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs) | |||
1889 | } | 1886 | } |
1890 | 1887 | ||
1891 | retval = coredump_wait(exit_code, &core_state); | 1888 | retval = coredump_wait(exit_code, &core_state); |
1892 | if (retval < 0) { | 1889 | if (retval < 0) |
1893 | put_cred(cred); | 1890 | goto fail_creds; |
1894 | goto fail; | ||
1895 | } | ||
1896 | 1891 | ||
1897 | old_cred = override_creds(cred); | 1892 | old_cred = override_creds(cred); |
1898 | 1893 | ||
@@ -2009,9 +2004,10 @@ fail_dropcount: | |||
2009 | if (ispipe) | 2004 | if (ispipe) |
2010 | atomic_dec(&core_dump_count); | 2005 | atomic_dec(&core_dump_count); |
2011 | fail_unlock: | 2006 | fail_unlock: |
2007 | coredump_finish(mm); | ||
2012 | revert_creds(old_cred); | 2008 | revert_creds(old_cred); |
2009 | fail_creds: | ||
2013 | put_cred(cred); | 2010 | put_cred(cred); |
2014 | coredump_finish(mm); | ||
2015 | fail: | 2011 | fail: |
2016 | return; | 2012 | return; |
2017 | } | 2013 | } |