From 45ac96701add332f044616229be156b081dbf81d Mon Sep 17 00:00:00 2001 From: rmacklem Date: Mon, 8 May 2017 19:50:35 +0000 Subject: MFC: r317296 Fix some krpc leaks for the NFSv4.1/pNFS client. The NFSv4.1/pNFS client wasn't doing a newnfs_disconnect() call for the connection to the Data Server (DS) under some circumstances. The main effect of this was a leak of malloc'd structures in the krpc. This patch adds the newnfs_disconnect() calls to fix this. Detected during recent testing against the pNFS server under development. --- sys/fs/nfsclient/nfs_clrpcops.c | 11 ++++++++--- sys/fs/nfsclient/nfs_clvfsops.c | 12 ++++++++++-- 2 files changed, 18 insertions(+), 5 deletions(-) (limited to 'sys/fs/nfsclient') diff --git a/sys/fs/nfsclient/nfs_clrpcops.c b/sys/fs/nfsclient/nfs_clrpcops.c index b071e66..32c6188 100644 --- a/sys/fs/nfsclient/nfs_clrpcops.c +++ b/sys/fs/nfsclient/nfs_clrpcops.c @@ -5399,10 +5399,13 @@ nfsrpc_fillsa(struct nfsmount *nmp, struct sockaddr_storage *ssp, NFSCL_DEBUG(3, "DS connect=%d\n", error); /* Now, do the exchangeid and create session. */ - if (error == 0) + if (error == 0) { error = nfsrpc_exchangeid(nmp, clp, nrp, NFSV4EXCH_USEPNFSDS, &dsp, nrp->nr_cred, p); - NFSCL_DEBUG(3, "DS exchangeid=%d\n", error); + NFSCL_DEBUG(3, "DS exchangeid=%d\n", error); + if (error != 0) + newnfs_disconnect(nrp); + } if (error == 0) { dsp->nfsclds_sockp = nrp; NFSLOCKMNT(nmp); @@ -5445,8 +5448,10 @@ nfsrpc_fillsa(struct nfsmount *nmp, struct sockaddr_storage *ssp, TAILQ_INSERT_TAIL(&nmp->nm_sess, dsp, nfsclds_list); NFSUNLOCKMNT(nmp); *dspp = dsp; - } else if (dsp != NULL) + } else if (dsp != NULL) { + newnfs_disconnect(nrp); nfscl_freenfsclds(dsp); + } return (error); } diff --git a/sys/fs/nfsclient/nfs_clvfsops.c b/sys/fs/nfsclient/nfs_clvfsops.c index 94fc380..51a1d90 100644 --- a/sys/fs/nfsclient/nfs_clvfsops.c +++ b/sys/fs/nfsclient/nfs_clvfsops.c @@ -1643,8 +1643,12 @@ bad: NFSUNLOCKCLSTATE(); free(nmp->nm_clp, M_NFSCLCLIENT); } - TAILQ_FOREACH_SAFE(dsp, &nmp->nm_sess, nfsclds_list, tdsp) + TAILQ_FOREACH_SAFE(dsp, &nmp->nm_sess, nfsclds_list, tdsp) { + if (dsp != TAILQ_FIRST(&nmp->nm_sess) && + dsp->nfsclds_sockp != NULL) + newnfs_disconnect(dsp->nfsclds_sockp); nfscl_freenfsclds(dsp); + } FREE(nmp, M_NEWNFSMNT); FREE(nam, M_SONAME); return (error); @@ -1709,8 +1713,12 @@ nfs_unmount(struct mount *mp, int mntflags) AUTH_DESTROY(nmp->nm_sockreq.nr_auth); mtx_destroy(&nmp->nm_sockreq.nr_mtx); mtx_destroy(&nmp->nm_mtx); - TAILQ_FOREACH_SAFE(dsp, &nmp->nm_sess, nfsclds_list, tdsp) + TAILQ_FOREACH_SAFE(dsp, &nmp->nm_sess, nfsclds_list, tdsp) { + if (dsp != TAILQ_FIRST(&nmp->nm_sess) && + dsp->nfsclds_sockp != NULL) + newnfs_disconnect(dsp->nfsclds_sockp); nfscl_freenfsclds(dsp); + } FREE(nmp, M_NEWNFSMNT); out: return (error); -- cgit v1.1