Commit 5e43aef530ba39206f7923295388f7ec3c5a7d93

Authored by Oleg Nesterov
Committed by Linus Torvalds
1 parent d5bf4c4f5f

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>

Showing 1 changed file with 6 additions and 10 deletions Side-by-side Diff

... ... @@ -1862,10 +1862,8 @@
1862 1862 goto fail;
1863 1863  
1864 1864 cred = prepare_creds();
1865   - if (!cred) {
1866   - retval = -ENOMEM;
  1865 + if (!cred)
1867 1866 goto fail;
1868   - }
1869 1867  
1870 1868 down_write(&mm->mmap_sem);
1871 1869 /*
... ... @@ -1873,8 +1871,7 @@
1873 1871 */
1874 1872 if (mm->core_state || !__get_dumpable(cprm.mm_flags)) {
1875 1873 up_write(&mm->mmap_sem);
1876   - put_cred(cred);
1877   - goto fail;
  1874 + goto fail_creds;
1878 1875 }
1879 1876  
1880 1877 /*
... ... @@ -1889,10 +1886,8 @@
1889 1886 }
1890 1887  
1891 1888 retval = coredump_wait(exit_code, &core_state);
1892   - if (retval < 0) {
1893   - put_cred(cred);
1894   - goto fail;
1895   - }
  1889 + if (retval < 0)
  1890 + goto fail_creds;
1896 1891  
1897 1892 old_cred = override_creds(cred);
1898 1893  
1899 1894  
1900 1895  
... ... @@ -2009,9 +2004,10 @@
2009 2004 if (ispipe)
2010 2005 atomic_dec(&core_dump_count);
2011 2006 fail_unlock:
  2007 + coredump_finish(mm);
2012 2008 revert_creds(old_cred);
  2009 +fail_creds:
2013 2010 put_cred(cred);
2014   - coredump_finish(mm);
2015 2011 fail:
2016 2012 return;
2017 2013 }