1
0
Fork 0

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: 0168b9e38c "procfs: switch instantiate_t to d_splice_alias()"
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
hifive-unleashed-5.1
Al Viro 2018-06-08 01:17:11 -04:00
parent 888e2b03ef
commit d85b399b64
1 changed files with 3 additions and 3 deletions

View File

@ -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);
}