Skip to contentSkip to conversation

NFSd: nfs4_preprocess_seqid_op should only set *stpp on success

PATCH In review Jeff Layton 3 participants 4 messages Jun 6, 2014 – Jun 7, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 NFSd: nfs4_preprocess_seqid_op should only set *stpp on success

From: Trond Myklebust <[email protected]>

---
 fs/nfsd/nfs4state.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
fs/nfsd/nfs4state.c +7 -3
index f429883fb4bb..f8c61c2a0a9e 100644
@@ -3897,6 +3897,7 @@ nfs4_preprocess_seqid_op(struct nfsd4_compound_state *cstate, u32 seqid,
 {
 	__be32 status;
 	struct nfs4_stid *s;
+	struct nfs4_ol_stateid *stp = NULL;
 
 	dprintk("NFSD: %s: seqid=%d stateid = " STATEID_FMT "\n", __func__,
 		seqid, STATEID_VAL(stateid));
@@ -3906,11 +3907,14 @@ nfs4_preprocess_seqid_op(struct nfsd4_compound_state *cstate, u32 seqid,
 				      cstate->minorversion, nn);
 	if (status)
 		return status;
-	*stpp = openlockstateid(s);
+	stp = openlockstateid(s);
 	if (!nfsd4_has_session(cstate))
-		cstate->replay_owner = (*stpp)->st_stateowner;
+		cstate->replay_owner = stp->st_stateowner;
 
-	return nfs4_seqid_op_checks(cstate, stateid, seqid, *stpp);
+	status = nfs4_seqid_op_checks(cstate, stateid, seqid, stp);
+	if (!status)
+		*stpp = stp;
+	return status;
 }
 
 static __be32 nfs4_preprocess_confirmed_seqid_op(struct nfsd4_compound_state *cstate, u32 seqid,
Signature · 1 line
1.9.3
#2 lore raw
Quoted 10 lines · On Sat, 7 Jun 2014 07:08:00 -0700 Christoph Hellwig <[email protected]> wrote:
Quoted 4 lines · Jeff Layton

From: Trond Myklebust <[email protected]>

The new code looks correct, but shouldn't callers already take care not to use the returned stateid only if nfs4_preprocess_seqid_op returns 0?

Yeah, I mentioned that to Bruce on IRC. This is not really a bugfix, per-se, but more of a defensive coding measure.

Signature · 1 line
Jeff Layton <[email protected]>