diff options
author | rmacklem <rmacklem@FreeBSD.org> | 2017-05-08 19:50:35 +0000 |
---|---|---|
committer | rmacklem <rmacklem@FreeBSD.org> | 2017-05-08 19:50:35 +0000 |
commit | 45ac96701add332f044616229be156b081dbf81d (patch) | |
tree | 777fccd8fe4e7eccf6e73e188b8fceb8b65d7543 /sys/fs | |
parent | 497902cc8c18e1b82992f4c4e2e02c86c5a518a0 (diff) | |
download | FreeBSD-src-45ac96701add332f044616229be156b081dbf81d.zip FreeBSD-src-45ac96701add332f044616229be156b081dbf81d.tar.gz |
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.
Diffstat (limited to 'sys/fs')
-rw-r--r-- | sys/fs/nfsclient/nfs_clrpcops.c | 11 | ||||
-rw-r--r-- | sys/fs/nfsclient/nfs_clvfsops.c | 12 |
2 files changed, 18 insertions, 5 deletions
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); |