NFSD: nfsd_unlink() clobbers non-zero status returned from fh_fill_pre_attrs()
authorChuck Lever <chuck.lever@oracle.com>
Sun, 26 Jan 2025 21:50:17 +0000 (16:50 -0500)
committerChuck Lever <chuck.lever@oracle.com>
Mon, 10 Mar 2025 13:10:56 +0000 (09:10 -0400)
If fh_fill_pre_attrs() returns a non-zero status, the error flow
takes it through out_unlock, which then overwrites the returned
status code with

err = nfserrno(host_err);

Fixes: a332018a91c4 ("nfsd: handle failure to collect pre/post-op attrs more sanely")
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Cc: stable@vger.kernel.org
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
fs/nfsd/vfs.c

index 188c978a0c7984af32bb418edb73a5e1a7f9e532..749dd84bdb419295fba251b4c586e6158bec21c9 100644 (file)
@@ -2010,11 +2010,9 @@ out_nfserr:
                 * error status.
                 */
                err = nfserr_file_open;
-       } else {
-               err = nfserrno(host_err);
        }
 out:
-       return err;
+       return err != nfs_ok ? err : nfserrno(host_err);
 out_unlock:
        inode_unlock(dirp);
        goto out_drop_write;