NFSv4: Fix a memory leak in nfs4_discover_server_trunking
authorTrond Myklebust <Trond.Myklebust@netapp.com>
Thu, 4 Apr 2013 19:55:00 +0000 (15:55 -0400)
committerTrond Myklebust <Trond.Myklebust@netapp.com>
Fri, 5 Apr 2013 20:59:15 +0000 (16:59 -0400)
When we assign a new rpc_client to clp->cl_rpcclient, we need to destroy
the old one.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Cc: Chuck Lever <chuck.lever@oracle.com>
Cc: stable@vger.kernel.org [>=3.7]
fs/nfs/nfs4state.c

index 6ace365c6334db844af0c2c3f221cd871ef3658c..d41a3518509fa5a0cf1dbbdcbed87f39fa3eff45 100644 (file)
@@ -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: