nfsd: minor consolidation of mach_cred handling code
authorJ. Bruce Fields <bfields@redhat.com>
Mon, 23 Nov 2015 22:39:12 +0000 (15:39 -0700)
committerJ. Bruce Fields <bfields@redhat.com>
Tue, 24 Nov 2015 17:39:18 +0000 (10:39 -0700)
Minor cleanup, no change in functionality.

Signed-off-by: J. Bruce Fields <bfields@redhat.com>
fs/nfsd/nfs4state.c

index 641604a221bc6f4a8bbd1bc41afe66be88811f50..efa3d4c09dabf389dd6a94f06630a3c59b4317d2 100644 (file)
@@ -2375,10 +2375,17 @@ nfsd4_exchange_id(struct svc_rqst *rqstp,
        if (exid->flags & ~EXCHGID4_FLAG_MASK_A)
                return nfserr_inval;
 
+       new = create_client(exid->clname, rqstp, &verf);
+       if (new == NULL)
+               return nfserr_jukebox;
+
        switch (exid->spa_how) {
        case SP4_MACH_CRED:
-               if (!svc_rqst_integrity_protected(rqstp))
-                       return nfserr_inval;
+               if (!svc_rqst_integrity_protected(rqstp)) {
+                       status = nfserr_inval;
+                       goto out_nolock;
+               }
+               new->cl_mach_cred = true;
        case SP4_NONE:
                break;
        default:                                /* checked by xdr code */
@@ -2387,10 +2394,6 @@ nfsd4_exchange_id(struct svc_rqst *rqstp,
                return nfserr_encr_alg_unsupp;
        }
 
-       new = create_client(exid->clname, rqstp, &verf);
-       if (new == NULL)
-               return nfserr_jukebox;
-
        /* Cases below refer to rfc 5661 section 18.35.4: */
        spin_lock(&nn->client_lock);
        conf = find_confirmed_client_by_name(&exid->clname, nn);
@@ -2452,7 +2455,6 @@ out_new:
                        goto out;
        }
        new->cl_minorversion = cstate->minorversion;
-       new->cl_mach_cred = (exid->spa_how == SP4_MACH_CRED);
 
        gen_clid(new, nn);
        add_to_unconfirmed(new);
@@ -2470,6 +2472,7 @@ out_copy:
 
 out:
        spin_unlock(&nn->client_lock);
+out_nolock:
        if (new)
                expire_client(new);
        if (unconf)