Commit d85b399b authored by Al Viro's avatar Al Viro

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: default avatarTetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
Fixes: 0168b9e3 "procfs: switch instantiate_t to d_splice_alias()"
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 888e2b03
...@@ -1891,19 +1891,19 @@ bool proc_fill_cache(struct file *file, struct dir_context *ctx, ...@@ -1891,19 +1891,19 @@ bool proc_fill_cache(struct file *file, struct dir_context *ctx,
struct dentry *res; struct dentry *res;
res = instantiate(child, task, ptr); res = instantiate(child, task, ptr);
d_lookup_done(child); d_lookup_done(child);
if (IS_ERR(res))
goto end_instantiate;
if (unlikely(res)) { if (unlikely(res)) {
dput(child); dput(child);
child = res; child = res;
if (IS_ERR(child))
goto end_instantiate;
} }
} }
} }
inode = d_inode(child); inode = d_inode(child);
ino = inode->i_ino; ino = inode->i_ino;
type = inode->i_mode >> 12; type = inode->i_mode >> 12;
end_instantiate:
dput(child); dput(child);
end_instantiate:
return dir_emit(ctx, name, len, ino, type); return dir_emit(ctx, name, len, ino, type);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment