From: Miklos Szeredi Date: Mon, 21 May 2012 15:30:11 +0000 (+0200) Subject: vfs: do_last(): check LOOKUP_DIRECTORY X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=af2f55426d1d888dcc0ba8dc9e9deb49fae38e38;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git vfs: do_last(): check LOOKUP_DIRECTORY Check for ENOTDIR before finishing open. This allows this code to be shared between O_CREAT and plain opens. Signed-off-by: Miklos Szeredi Signed-off-by: Al Viro --- diff --git a/fs/namei.c b/fs/namei.c index a7e994bb78c2..4767c0588b6e 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -2386,6 +2386,9 @@ static struct file *do_last(struct nameidata *nd, struct path *path, error = -EISDIR; if (S_ISDIR(nd->inode->i_mode)) goto exit; + error = -ENOTDIR; + if ((nd->flags & LOOKUP_DIRECTORY) && !nd->inode->i_op->lookup) + goto exit; ok: if (!S_ISREG(nd->inode->i_mode)) will_truncate = 0;