Commit 10fa8e62f2bc33c452516585911f151d88389e4c
1 parent
9e67f36169
Exists in
master
and in
20 other branches
Unify exits in O_CREAT handling
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Showing 1 changed file with 13 additions and 17 deletions Side-by-side Diff
fs/namei.c
... | ... | @@ -1821,9 +1821,8 @@ |
1821 | 1821 | nd.flags |= LOOKUP_REVAL; |
1822 | 1822 | error = path_walk(pathname, &nd); |
1823 | 1823 | if (error) { |
1824 | - if (nd.root.mnt) | |
1825 | - path_put(&nd.root); | |
1826 | - return ERR_PTR(error); | |
1824 | + filp = ERR_PTR(error); | |
1825 | + goto out; | |
1827 | 1826 | } |
1828 | 1827 | if (unlikely(!audit_dummy_context())) |
1829 | 1828 | audit_inode(pathname, nd.path.dentry); |
... | ... | @@ -1847,9 +1846,7 @@ |
1847 | 1846 | filp = do_last(&nd, &path, open_flag, acc_mode, mode, pathname); |
1848 | 1847 | if (!filp) |
1849 | 1848 | goto do_link; |
1850 | - if (nd.root.mnt) | |
1851 | - path_put(&nd.root); | |
1852 | - return filp; | |
1849 | + goto out; | |
1853 | 1850 | |
1854 | 1851 | exit_dput: |
1855 | 1852 | path_put_conditional(&path, &nd); |
1856 | 1853 | |
... | ... | @@ -1857,9 +1854,15 @@ |
1857 | 1854 | release_open_intent(&nd); |
1858 | 1855 | exit_parent: |
1859 | 1856 | path_put(&nd.path); |
1857 | + filp = ERR_PTR(error); | |
1858 | +out: | |
1860 | 1859 | if (nd.root.mnt) |
1861 | 1860 | path_put(&nd.root); |
1862 | - return ERR_PTR(error); | |
1861 | + if (filp == ERR_PTR(-ESTALE) && !force_reval) { | |
1862 | + force_reval = 1; | |
1863 | + goto reval; | |
1864 | + } | |
1865 | + return filp; | |
1863 | 1866 | |
1864 | 1867 | do_link: |
1865 | 1868 | error = -ELOOP; |
... | ... | @@ -1887,13 +1890,8 @@ |
1887 | 1890 | * with "intent.open". |
1888 | 1891 | */ |
1889 | 1892 | release_open_intent(&nd); |
1890 | - if (nd.root.mnt) | |
1891 | - path_put(&nd.root); | |
1892 | - if (error == -ESTALE && !force_reval) { | |
1893 | - force_reval = 1; | |
1894 | - goto reval; | |
1895 | - } | |
1896 | - return ERR_PTR(error); | |
1893 | + filp = ERR_PTR(error); | |
1894 | + goto out; | |
1897 | 1895 | } |
1898 | 1896 | nd.flags &= ~LOOKUP_PARENT; |
1899 | 1897 | filp = do_last(&nd, &path, open_flag, acc_mode, mode, pathname); |
... | ... | @@ -1901,9 +1899,7 @@ |
1901 | 1899 | __putname(nd.last.name); |
1902 | 1900 | if (!filp) |
1903 | 1901 | goto do_link; |
1904 | - if (nd.root.mnt) | |
1905 | - path_put(&nd.root); | |
1906 | - return filp; | |
1902 | + goto out; | |
1907 | 1903 | } |
1908 | 1904 | |
1909 | 1905 | /** |