Skip to content

Commit

Permalink
NFSv4: Fix a memory leak in nfs4_discover_server_trunking
Browse files Browse the repository at this point in the history
When we assign a new rpc_client to clp->cl_rpcclient, we need to destroy
the old one.

Signed-off-by: Trond Myklebust <[email protected]>
Cc: Chuck Lever <[email protected]>
Cc: [email protected] [>=3.7]
  • Loading branch information
Trond Myklebust authored and Trond Myklebust committed Apr 5, 2013
1 parent a58e0be commit b193d59
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion fs/nfs/nfs4state.c
Original file line number Diff line number Diff line change
Expand Up @@ -1886,7 +1886,13 @@ int nfs4_discover_server_trunking(struct nfs_client *clp,
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:
Expand Down

0 comments on commit b193d59

Please sign in to comment.