From: Trond Myklebust Date: Thu, 4 Apr 2013 19:55:00 +0000 (-0400) Subject: NFSv4: Fix a memory leak in nfs4_discover_server_trunking X-Git-Tag: v3.9-rc7~29^2~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b193d59a4863ea670872d76dc99231ddeb598625;p=profile%2Fcommon%2Fkernel-common.git NFSv4: Fix a memory leak in nfs4_discover_server_trunking When we assign a new rpc_client to clp->cl_rpcclient, we need to destroy the old one. Signed-off-by: Trond Myklebust Cc: Chuck Lever Cc: stable@vger.kernel.org [>=3.7] --- diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c index 6ace365..d41a351 100644 --- a/fs/nfs/nfs4state.c +++ b/fs/nfs/nfs4state.c @@ -1886,7 +1886,13 @@ again: status = PTR_ERR(clnt); break; } - clp->cl_rpcclient = clnt; + /* Note: this is safe because we haven't yet marked the + * client as ready, so we are the only user of + * clp->cl_rpcclient + */ + clnt = xchg(&clp->cl_rpcclient, clnt); + rpc_shutdown_client(clnt); + clnt = clp->cl_rpcclient; goto again; case -NFS4ERR_MINOR_VERS_MISMATCH: