From d85b399b64e85a311c09205c675d4ae1c5af6246 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Fri, 8 Jun 2018 01:17:11 -0400 Subject: 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 Fixes: 0168b9e38c42 "procfs: switch instantiate_t to d_splice_alias()" Signed-off-by: Al Viro --- fs/proc/base.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'fs/proc') diff --git a/fs/proc/base.c b/fs/proc/base.c index de22c20..6f92734 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, struct dentry *res; res = instantiate(child, task, ptr); d_lookup_done(child); - if (IS_ERR(res)) - goto end_instantiate; if (unlikely(res)) { dput(child); child = res; + if (IS_ERR(child)) + goto end_instantiate; } } } inode = d_inode(child); ino = inode->i_ino; type = inode->i_mode >> 12; -end_instantiate: dput(child); +end_instantiate: return dir_emit(ctx, name, len, ino, type); } -- cgit v1.1