aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2018-06-08 01:17:11 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2018-06-08 01:17:11 -0400
commitd85b399b64e85a311c09205c675d4ae1c5af6246 (patch)
tree249253d72c6915fc5523bbb3336a2a932c430245
parent888e2b03ef56694290e58bd9ac23f8033bf6369f (diff)
fix proc_fill_cache() in case of d_alloc_parallel() failure
If d_alloc_parallel() returns ERR_PTR(...), we don't want to dput() that. Small reorganization allows to have all error-in-lookup cases rejoin the main codepath after dput(child), avoiding the entire problem. Spotted-by: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp> Fixes: 0168b9e38c42 "procfs: switch instantiate_t to d_splice_alias()" Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r--fs/proc/base.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/fs/proc/base.c b/fs/proc/base.c
index de22c2002b38..6f927340db0a 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -1891,19 +1891,19 @@ bool proc_fill_cache(struct file *file, struct dir_context *ctx,
1891 struct dentry *res; 1891 struct dentry *res;
1892 res = instantiate(child, task, ptr); 1892 res = instantiate(child, task, ptr);
1893 d_lookup_done(child); 1893 d_lookup_done(child);
1894 if (IS_ERR(res))
1895 goto end_instantiate;
1896 if (unlikely(res)) { 1894 if (unlikely(res)) {
1897 dput(child); 1895 dput(child);
1898 child = res; 1896 child = res;
1897 if (IS_ERR(child))
1898 goto end_instantiate;
1899 } 1899 }
1900 } 1900 }
1901 } 1901 }
1902 inode = d_inode(child); 1902 inode = d_inode(child);
1903 ino = inode->i_ino; 1903 ino = inode->i_ino;
1904 type = inode->i_mode >> 12; 1904 type = inode->i_mode >> 12;
1905end_instantiate:
1906 dput(child); 1905 dput(child);
1906end_instantiate:
1907 return dir_emit(ctx, name, len, ino, type); 1907 return dir_emit(ctx, name, len, ino, type);
1908} 1908}
1909 1909