From: Trond Myklebust Date: Wed, 30 Jul 2014 12:27:09 +0000 (-0400) Subject: nfsd: Ensure lookup_clientid() takes client_lock X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=3e339f964b74b7223ab128f36f4b2aaf9dc12eb9;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git nfsd: Ensure lookup_clientid() takes client_lock Ensure that the client lookup is done safely under the client_lock, so we're not relying on the client_mutex. Signed-off-by: Trond Myklebust Signed-off-by: J. Bruce Fields --- diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 68383b09c7dc..f9d077d800ee 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -3451,13 +3451,17 @@ static __be32 lookup_clientid(clientid_t *clid, * will be false. */ WARN_ON_ONCE(cstate->session); + spin_lock(&nn->client_lock); found = find_confirmed_client(clid, false, nn); - if (!found) + if (!found) { + spin_unlock(&nn->client_lock); return nfserr_expired; + } + atomic_inc(&found->cl_refcount); + spin_unlock(&nn->client_lock); /* Cache the nfs4_client in cstate! */ cstate->clp = found; - atomic_inc(&found->cl_refcount); return nfs_ok; }