]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
nfsd: only fill out return pointer on success in nfsd4_lookup_stateid
authorJeff Layton <jlayton@kernel.org>
Mon, 26 Sep 2022 16:38:44 +0000 (12:38 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 10 Apr 2024 14:19:19 +0000 (16:19 +0200)
[ Upstream commit 4d01416ab41540bb13ec4a39ac4e6c4aa5934bc9 ]

In the case of a revoked delegation, we still fill out the pointer even
when returning an error, which is bad form. Only overwrite the pointer
on success.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
fs/nfsd/nfs4state.c

index f427f95ab934e3d094fe57f6cc3b0ebb52dfc97f..1e9245303c0f2cae93565c423d1d98ac347988b4 100644 (file)
@@ -6279,6 +6279,7 @@ nfsd4_lookup_stateid(struct nfsd4_compound_state *cstate,
                     struct nfs4_stid **s, struct nfsd_net *nn)
 {
        __be32 status;
+       struct nfs4_stid *stid;
        bool return_revoked = false;
 
        /*
@@ -6301,15 +6302,16 @@ nfsd4_lookup_stateid(struct nfsd4_compound_state *cstate,
        }
        if (status)
                return status;
-       *s = find_stateid_by_type(cstate->clp, stateid, typemask);
-       if (!*s)
+       stid = find_stateid_by_type(cstate->clp, stateid, typemask);
+       if (!stid)
                return nfserr_bad_stateid;
-       if (((*s)->sc_type == NFS4_REVOKED_DELEG_STID) && !return_revoked) {
-               nfs4_put_stid(*s);
+       if ((stid->sc_type == NFS4_REVOKED_DELEG_STID) && !return_revoked) {
+               nfs4_put_stid(stid);
                if (cstate->minorversion)
                        return nfserr_deleg_revoked;
                return nfserr_bad_stateid;
        }
+       *s = stid;
        return nfs_ok;
 }