]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
simplify nfs_atomic_open_v23()
authorAl Viro <viro@zeniv.linux.org.uk>
Fri, 12 Sep 2025 15:52:41 +0000 (11:52 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 24 Nov 2025 09:35:54 +0000 (10:35 +0100)
[ Upstream commit aae9db5739164353fa1894db000fabad940a835b ]

1) finish_no_open() takes ERR_PTR() as dentry now.
2) caller of ->atomic_open() will call d_lookup_done() itself, no
need to do it here.

Reviewed-by: NeilBrown <neil@brown.name>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Stable-dep-of: 85d2c2392ac6 ("NFSv2/v3: Fix error handling in nfs_atomic_open_v23()")
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/nfs/dir.c

index bbc625e742aa301a33685bb80ac0854f31e0382c..c05c737ac5282bf02ec7d487fff19ed944993a2b 100644 (file)
@@ -2270,7 +2270,7 @@ int nfs_atomic_open_v23(struct inode *dir, struct dentry *dentry,
                        struct file *file, unsigned int open_flags,
                        umode_t mode)
 {
-
+       struct dentry *res = NULL;
        /* Same as look+open from lookup_open(), but with different O_TRUNC
         * handling.
         */
@@ -2285,21 +2285,15 @@ int nfs_atomic_open_v23(struct inode *dir, struct dentry *dentry,
                if (error)
                        return error;
                return finish_open(file, dentry, NULL);
-       } else if (d_in_lookup(dentry)) {
+       }
+       if (d_in_lookup(dentry)) {
                /* The only flags nfs_lookup considers are
                 * LOOKUP_EXCL and LOOKUP_RENAME_TARGET, and
                 * we want those to be zero so the lookup isn't skipped.
                 */
-               struct dentry *res = nfs_lookup(dir, dentry, 0);
-
-               d_lookup_done(dentry);
-               if (unlikely(res)) {
-                       if (IS_ERR(res))
-                               return PTR_ERR(res);
-                       return finish_no_open(file, res);
-               }
+               res = nfs_lookup(dir, dentry, 0);
        }
-       return finish_no_open(file, NULL);
+       return finish_no_open(file, res);
 
 }
 EXPORT_SYMBOL_GPL(nfs_atomic_open_v23);