]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
SUNRPC: Ensure get_rpccred() and put_rpccred() can take NULL arguments
authorTrond Myklebust <trond.myklebust@primarydata.com>
Mon, 16 May 2016 21:42:42 +0000 (17:42 -0400)
committerAnna Schumaker <Anna.Schumaker@Netapp.com>
Tue, 17 May 2016 19:48:06 +0000 (15:48 -0400)
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
include/linux/sunrpc/auth.h
net/sunrpc/auth.c

index 6f36b2bf3e05c71e0054cfda76768debc908e2b8..899791573a403ba8434c12a05b4594f23ac6c33b 100644 (file)
@@ -202,7 +202,8 @@ char *                      rpcauth_stringify_acceptor(struct rpc_cred *);
 static inline
 struct rpc_cred *      get_rpccred(struct rpc_cred *cred)
 {
-       atomic_inc(&cred->cr_count);
+       if (cred != NULL)
+               atomic_inc(&cred->cr_count);
        return cred;
 }
 
index e0bb30fd2ed3e8e16f474dca615a4bb5206cf889..040ff627c18a52f463e6a27e06b3794f4b0b5b10 100644 (file)
@@ -703,8 +703,7 @@ rpcauth_bindcred(struct rpc_task *task, struct rpc_cred *cred, int flags)
                new = rpcauth_bind_new_cred(task, lookupflags);
        if (IS_ERR(new))
                return PTR_ERR(new);
-       if (req->rq_cred != NULL)
-               put_rpccred(req->rq_cred);
+       put_rpccred(req->rq_cred);
        req->rq_cred = new;
        return 0;
 }
@@ -712,6 +711,8 @@ rpcauth_bindcred(struct rpc_task *task, struct rpc_cred *cred, int flags)
 void
 put_rpccred(struct rpc_cred *cred)
 {
+       if (cred == NULL)
+               return;
        /* Fast path for unhashed credentials */
        if (test_bit(RPCAUTH_CRED_HASHED, &cred->cr_flags) == 0) {
                if (atomic_dec_and_test(&cred->cr_count))