SUNRPC: Fix potential race in put_rpccred()
authorTrond Myklebust <Trond.Myklebust@netapp.com>
Tue, 28 Oct 2008 19:21:42 +0000 (15:21 -0400)
committerTrond Myklebust <Trond.Myklebust@netapp.com>
Tue, 28 Oct 2008 19:21:42 +0000 (15:21 -0400)
We have to be careful when we try to unhash the credential in
put_rpccred(), because we're not holding the credcache lock, so the call to
rpcauth_unhash_cred() may fail if someone else has looked the cred up, and
obtained a reference to it.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
net/sunrpc/auth.c

index a045a12..cb216b2 100644 (file)
@@ -455,7 +455,7 @@ need_lock:
        }
        if (test_bit(RPCAUTH_CRED_UPTODATE, &cred->cr_flags) == 0)
                rpcauth_unhash_cred(cred);
-       else if (test_bit(RPCAUTH_CRED_HASHED, &cred->cr_flags) != 0) {
+       if (test_bit(RPCAUTH_CRED_HASHED, &cred->cr_flags) != 0) {
                cred->cr_expire = jiffies;
                list_add_tail(&cred->cr_lru, &cred_unused);
                number_cred_unused++;