aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/nfsserver/nfs_srvkrpc.c1
-rw-r--r--sys/nlm/nlm_prot_impl.c6
-rw-r--r--sys/rpc/svc.c1
-rw-r--r--sys/rpc/svc_generic.c5
-rw-r--r--sys/rpc/svc_vc.c9
5 files changed, 18 insertions, 4 deletions
diff --git a/sys/nfsserver/nfs_srvkrpc.c b/sys/nfsserver/nfs_srvkrpc.c
index 6fe28aa64e37..99edac5b7d18 100644
--- a/sys/nfsserver/nfs_srvkrpc.c
+++ b/sys/nfsserver/nfs_srvkrpc.c
@@ -467,6 +467,7 @@ nfssvc_addsock(struct file *fp, struct thread *td)
fp->f_data = NULL;
svc_reg(xprt, NFS_PROG, NFS_VER2, nfssvc_program, NULL);
svc_reg(xprt, NFS_PROG, NFS_VER3, nfssvc_program, NULL);
+ SVC_RELEASE(xprt);
}
return (0);
diff --git a/sys/nlm/nlm_prot_impl.c b/sys/nlm/nlm_prot_impl.c
index 6ee6baa282ac..049c7ba97508 100644
--- a/sys/nlm/nlm_prot_impl.c
+++ b/sys/nlm/nlm_prot_impl.c
@@ -1389,7 +1389,7 @@ nlm_register_services(SVCPOOL *pool, int addr_count, char **addrs)
return (EINVAL);
}
- xprts = malloc(addr_count * sizeof(SVCXPRT *), M_NLM, M_WAITOK);
+ xprts = malloc(addr_count * sizeof(SVCXPRT *), M_NLM, M_WAITOK|M_ZERO);
for (i = 0; i < version_count; i++) {
for (j = 0; j < addr_count; j++) {
/*
@@ -1447,6 +1447,10 @@ nlm_register_services(SVCPOOL *pool, int addr_count, char **addrs)
}
error = 0;
out:
+ for (j = 0; j < addr_count; j++) {
+ if (xprts[j])
+ SVC_RELEASE(xprts[j]);
+ }
free(xprts, M_NLM);
return (error);
}
diff --git a/sys/rpc/svc.c b/sys/rpc/svc.c
index 8c3bd2c96292..a59489457f61 100644
--- a/sys/rpc/svc.c
+++ b/sys/rpc/svc.c
@@ -276,6 +276,7 @@ xprt_register(SVCXPRT *xprt)
{
SVCPOOL *pool = xprt->xp_pool;
+ SVC_ACQUIRE(xprt);
mtx_lock(&pool->sp_lock);
xprt->xp_registered = TRUE;
xprt->xp_active = FALSE;
diff --git a/sys/rpc/svc_generic.c b/sys/rpc/svc_generic.c
index 790b4bab463d..38380f25defe 100644
--- a/sys/rpc/svc_generic.c
+++ b/sys/rpc/svc_generic.c
@@ -120,8 +120,10 @@ svc_create(
/* It was not found. Now create a new one */
xprt = svc_tp_create(pool, dispatch, prognum, versnum,
NULL, nconf);
- if (xprt)
+ if (xprt) {
num++;
+ SVC_RELEASE(xprt);
+ }
}
}
__rpc_endconf(handle);
@@ -179,6 +181,7 @@ svc_tp_create(
(unsigned)prognum, (unsigned)versnum,
nconf->nc_netid);
xprt_unregister(xprt);
+ SVC_RELEASE(xprt);
return (NULL);
}
return (xprt);
diff --git a/sys/rpc/svc_vc.c b/sys/rpc/svc_vc.c
index d8059b3f551a..b7da5e22787d 100644
--- a/sys/rpc/svc_vc.c
+++ b/sys/rpc/svc_vc.c
@@ -324,6 +324,7 @@ svc_vc_rendezvous_recv(SVCXPRT *xprt, struct rpc_msg *msg,
struct socket *so = NULL;
struct sockaddr *sa = NULL;
int error;
+ SVCXPRT *new_xprt;
/*
* The socket upcall calls xprt_active() which will eventually
@@ -383,10 +384,14 @@ svc_vc_rendezvous_recv(SVCXPRT *xprt, struct rpc_msg *msg,
/*
* svc_vc_create_conn will call xprt_register - we don't need
- * to do anything with the new connection.
+ * to do anything with the new connection except derefence it.
*/
- if (!svc_vc_create_conn(xprt->xp_pool, so, sa))
+ new_xprt = svc_vc_create_conn(xprt->xp_pool, so, sa);
+ if (!new_xprt) {
soclose(so);
+ } else {
+ SVC_RELEASE(new_xprt);
+ }
free(sa, M_SONAME);