Skip to contentSkip to conversation

NFSv4: Fix a memory leak in nfs4_discover_server_trunking

PATCH New Trond Myklebust 1 participant 1 message Apr 4, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 fs/nfs/nfs4state.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
fs/nfs/nfs4state.c +7 -1
index 0922b94..51b46c6 100644
@@ -1905,7 +1905,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:
Signature · 1 line
1.8.1.4