From: Al Viro Date: Wed, 8 Jun 2016 01:53:51 +0000 (-0400) Subject: fix a regression in atomic_open() X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=a01e718f7241c53f564402f7acff373eed5bd166;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git fix a regression in atomic_open() open("/foo/no_such_file", O_RDONLY | O_CREAT) on should fail with EACCES when /foo is not writable; failing with ENOENT is obviously wrong. That got broken by a braino introduced when moving the creat_error logics from atomic_open() to lookup_open(). Easy to fix, fortunately. Spotted-by: "Yan, Zheng" Tested-by: "Yan, Zheng" Signed-off-by: Al Viro --- diff --git a/fs/namei.c b/fs/namei.c index d7c0cac56d89..28cb1cd8507c 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -2995,9 +2995,13 @@ static int atomic_open(struct nameidata *nd, struct dentry *dentry, } if (*opened & FILE_CREATED) fsnotify_create(dir, dentry); - path->dentry = dentry; - path->mnt = nd->path.mnt; - return 1; + if (unlikely(d_is_negative(dentry))) { + error = -ENOENT; + } else { + path->dentry = dentry; + path->mnt = nd->path.mnt; + return 1; + } } } dput(dentry);