summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/compat/hpux/hpux_net.c32
-rw-r--r--sys/compat/sunos/sunos_misc.c3
-rw-r--r--sys/compat/ultrix/ultrix_misc.c3
-rw-r--r--sys/kern/uipc_syscalls.c59
-rw-r--r--sys/miscfs/portal/portal_vfsops.c8
-rw-r--r--sys/nfs/nfs_syscalls.c3
6 files changed, 53 insertions, 55 deletions
diff --git a/sys/compat/hpux/hpux_net.c b/sys/compat/hpux/hpux_net.c
index d7280311938..50354b2d45b 100644
--- a/sys/compat/hpux/hpux_net.c
+++ b/sys/compat/hpux/hpux_net.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hpux_net.c,v 1.8 2002/03/14 01:26:49 millert Exp $ */
+/* $OpenBSD: hpux_net.c,v 1.9 2002/08/23 22:21:43 art Exp $ */
/* $NetBSD: hpux_net.c,v 1.14 1997/04/01 19:59:02 scottr Exp $ */
/*
@@ -214,16 +214,16 @@ hpux_sys_setsockopt(p, v, retval)
if ((error = getsock(p->p_fd, SCARG(uap, s), &fp)))
return (error);
- if (SCARG(uap, valsize) > MLEN)
- return (EINVAL);
- FREF(fp);
+ if (SCARG(uap, valsize) > MLEN) {
+ error = EINVAL;
+ goto bad;
+ }
if (SCARG(uap, val)) {
m = m_get(M_WAIT, MT_SOOPTS);
if ((error = copyin(SCARG(uap, val), mtod(m, caddr_t),
(u_int)SCARG(uap, valsize)))) {
- FRELE(fp);
(void) m_free(m);
- return (error);
+ goto bad;
}
if (SCARG(uap, name) == SO_LINGER) {
tmp = *mtod(m, int *);
@@ -240,6 +240,7 @@ hpux_sys_setsockopt(p, v, retval)
}
error = sosetopt((struct socket *)fp->f_data, SCARG(uap, level),
SCARG(uap, name), m);
+bad:
FRELE(fp);
return (error);
}
@@ -258,21 +259,22 @@ hpux_sys_setsockopt2(p, v, retval)
if ((error = getsock(p->p_fd, SCARG(uap, s), &fp)))
return (error);
- if (SCARG(uap, valsize) > MLEN)
- return (EINVAL);
- FREF(fp);
+ if (SCARG(uap, valsize) > MLEN) {
+ error = EINVAL;
+ goto bad;
+ }
if (SCARG(uap, val)) {
m = m_get(M_WAIT, MT_SOOPTS);
if ((error = copyin(SCARG(uap, val), mtod(m, caddr_t),
(u_int)SCARG(uap, valsize)))) {
- FRELE(fp);
- (void) m_free(m);
- return (error);
+ m_free(m);
+ goto bad;
}
socksetsize(SCARG(uap, valsize), m);
}
error = sosetopt((struct socket *)fp->f_data, SCARG(uap, level),
SCARG(uap, name), m);
+bad:
FRELE(fp);
return (error);
}
@@ -290,12 +292,10 @@ hpux_sys_getsockopt(p, v, retval)
if ((error = getsock(p->p_fd, SCARG(uap, s), &fp)))
return (error);
- FREF(fp);
if (SCARG(uap, val)) {
if ((error = copyin((caddr_t)SCARG(uap, avalsize),
(caddr_t)&valsize, sizeof (valsize)))) {
- FRELE(fp);
- return (error);
+ goto bad;
}
} else
valsize = 0;
@@ -321,6 +321,6 @@ hpux_sys_getsockopt(p, v, retval)
bad:
FRELE(fp);
if (m != NULL)
- (void) m_free(m);
+ m_free(m);
return (error);
}
diff --git a/sys/compat/sunos/sunos_misc.c b/sys/compat/sunos/sunos_misc.c
index a1d582100ce..2b9272331e4 100644
--- a/sys/compat/sunos/sunos_misc.c
+++ b/sys/compat/sunos/sunos_misc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sunos_misc.c,v 1.40 2002/08/23 15:39:31 art Exp $ */
+/* $OpenBSD: sunos_misc.c,v 1.41 2002/08/23 22:21:44 art Exp $ */
/* $NetBSD: sunos_misc.c,v 1.65 1996/04/22 01:44:31 christos Exp $ */
/*
@@ -531,7 +531,6 @@ sunos_sys_setsockopt(p, v, retval)
if ((error = getsock(p->p_fd, SCARG(uap, s), &fp)) != 0)
return (error);
- FREF(fp);
#define SO_DONTLINGER (~SO_LINGER)
if (SCARG(uap, name) == SO_DONTLINGER) {
m = m_get(M_WAIT, MT_SOOPTS);
diff --git a/sys/compat/ultrix/ultrix_misc.c b/sys/compat/ultrix/ultrix_misc.c
index 2f86fdb9241..dfd9ef7ce58 100644
--- a/sys/compat/ultrix/ultrix_misc.c
+++ b/sys/compat/ultrix/ultrix_misc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ultrix_misc.c,v 1.27 2002/08/23 01:13:09 pvalchev Exp $ */
+/* $OpenBSD: ultrix_misc.c,v 1.28 2002/08/23 22:21:44 art Exp $ */
/* $NetBSD: ultrix_misc.c,v 1.23 1996/04/07 17:23:04 jonathan Exp $ */
/*
@@ -353,7 +353,6 @@ ultrix_sys_setsockopt(p, v, retval)
if ((error = getsock(p->p_fd, SCARG(uap, s), &fp)) != 0)
return (error);
- FREF(fp);
#define SO_DONTLINGER (~SO_LINGER)
if (SCARG(uap, name) == SO_DONTLINGER) {
m = m_get(M_WAIT, MT_SOOPTS);
diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c
index 4162dc34357..563903c2789 100644
--- a/sys/kern/uipc_syscalls.c
+++ b/sys/kern/uipc_syscalls.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uipc_syscalls.c,v 1.52 2002/05/23 14:59:24 art Exp $ */
+/* $OpenBSD: uipc_syscalls.c,v 1.53 2002/08/23 22:21:44 art Exp $ */
/* $NetBSD: uipc_syscalls.c,v 1.19 1996/02/09 19:00:48 christos Exp $ */
/*
@@ -115,7 +115,6 @@ sys_bind(p, v, retval)
if ((error = getsock(p->p_fd, SCARG(uap, s), &fp)) != 0)
return (error);
- FREF(fp);
error = sockargs(&nam, (caddr_t)SCARG(uap, name), SCARG(uap, namelen),
MT_SONAME);
if (error == 0) {
@@ -142,7 +141,6 @@ sys_listen(p, v, retval)
if ((error = getsock(p->p_fd, SCARG(uap, s), &fp)) != 0)
return (error);
- FREF(fp);
error = solisten((struct socket *)fp->f_data, SCARG(uap, backlog));
FRELE(fp);
return (error);
@@ -171,7 +169,6 @@ sys_accept(p, v, retval)
return (error);
if ((error = getsock(p->p_fd, SCARG(uap, s), &fp)) != 0)
return (error);
- FREF(fp);
headfp = fp;
s = splsoftnet();
head = (struct socket *)fp->f_data;
@@ -283,9 +280,10 @@ sys_connect(p, v, retval)
if ((error = getsock(p->p_fd, SCARG(uap, s), &fp)) != 0)
return (error);
so = (struct socket *)fp->f_data;
- if ((so->so_state & SS_NBIO) && (so->so_state & SS_ISCONNECTING))
+ if ((so->so_state & SS_NBIO) && (so->so_state & SS_ISCONNECTING)) {
+ FRELE(fp);
return (EALREADY);
- FREF(fp);
+ }
error = sockargs(&nam, (caddr_t)SCARG(uap, name), SCARG(uap, namelen),
MT_SONAME);
if (error)
@@ -480,6 +478,8 @@ sendit(p, s, mp, flags, retsize)
struct iovec *ktriov = NULL;
#endif
+ to = NULL;
+
if ((error = getsock(p->p_fd, s, &fp)) != 0)
return (error);
auio.uio_iov = mp->msg_iov;
@@ -493,19 +493,17 @@ sendit(p, s, mp, flags, retsize)
for (i = 0; i < mp->msg_iovlen; i++, iov++) {
/* Don't allow sum > SSIZE_MAX */
if (iov->iov_len > SSIZE_MAX ||
- (auio.uio_resid += iov->iov_len) > SSIZE_MAX)
- return (EINVAL);
+ (auio.uio_resid += iov->iov_len) > SSIZE_MAX) {
+ error = EINVAL;
+ goto bad;
+ }
}
- FREF(fp);
if (mp->msg_name) {
error = sockargs(&to, mp->msg_name, mp->msg_namelen,
MT_SONAME);
- if (error) {
- FRELE(fp);
- return (error);
- }
- } else
- to = 0;
+ if (error)
+ goto bad;
+ }
if (mp->msg_control) {
if (mp->msg_controllen < sizeof(struct cmsghdr)
#ifdef COMPAT_OLDSOCK
@@ -666,7 +664,7 @@ recvit(p, s, mp, namelenp, retsize)
register int i;
size_t len;
int error;
- struct mbuf *from = 0, *control = 0;
+ struct mbuf *from = NULL, *control = NULL;
#ifdef KTRACE
struct iovec *ktriov = NULL;
#endif
@@ -684,10 +682,11 @@ recvit(p, s, mp, namelenp, retsize)
for (i = 0; i < mp->msg_iovlen; i++, iov++) {
/* Don't allow sum > SSIZE_MAX */
if (iov->iov_len > SSIZE_MAX ||
- (auio.uio_resid += iov->iov_len) > SSIZE_MAX)
- return (EINVAL);
+ (auio.uio_resid += iov->iov_len) > SSIZE_MAX) {
+ error = EINVAL;
+ goto out;
+ }
}
- FREF(fp);
#ifdef KTRACE
if (KTRPOINT(p, KTR_GENIO)) {
int iovlen = auio.uio_iovcnt * sizeof (struct iovec);
@@ -820,7 +819,6 @@ sys_shutdown(p, v, retval)
if ((error = getsock(p->p_fd, SCARG(uap, s), &fp)) != 0)
return (error);
- FREF(fp);
error = soshutdown((struct socket *)fp->f_data, SCARG(uap, how));
FRELE(fp);
return (error);
@@ -846,9 +844,10 @@ sys_setsockopt(p, v, retval)
if ((error = getsock(p->p_fd, SCARG(uap, s), &fp)) != 0)
return (error);
- if (SCARG(uap, valsize) > MCLBYTES)
- return (EINVAL);
- FREF(fp);
+ if (SCARG(uap, valsize) > MCLBYTES) {
+ error = EINVAL;
+ goto bad;
+ }
if (SCARG(uap, val)) {
m = m_get(M_WAIT, MT_SOOPTS);
if (SCARG(uap, valsize) > MLEN) {
@@ -900,7 +899,6 @@ sys_getsockopt(p, v, retval)
if ((error = getsock(p->p_fd, SCARG(uap, s), &fp)) != 0)
return (error);
- FREF(fp);
if (SCARG(uap, val)) {
error = copyin((caddr_t)SCARG(uap, avalsize),
(caddr_t)&valsize, sizeof (valsize));
@@ -971,7 +969,6 @@ sys_getsockname(p, v, retval)
if ((error = getsock(p->p_fd, SCARG(uap, fdes), &fp)) != 0)
return (error);
- FREF(fp);
error = copyin((caddr_t)SCARG(uap, alen), (caddr_t)&len, sizeof (len));
if (error)
goto bad;
@@ -1017,9 +1014,10 @@ sys_getpeername(p, v, retval)
if ((error = getsock(p->p_fd, SCARG(uap, fdes), &fp)) != 0)
return (error);
so = (struct socket *)fp->f_data;
- if ((so->so_state & (SS_ISCONNECTED|SS_ISCONFIRMING)) == 0)
+ if ((so->so_state & (SS_ISCONNECTED|SS_ISCONFIRMING)) == 0) {
+ FRELE(fp);
return (ENOTCONN);
- FREF(fp);
+ }
error = copyin((caddr_t)SCARG(uap, alen), (caddr_t)&len, sizeof (len));
if (error)
goto bad;
@@ -1063,9 +1061,10 @@ sys_getpeereid(p, v, retval)
if ((error = getsock(p->p_fd, SCARG(uap, fdes), &fp)) != 0)
return (error);
so = (struct socket *)fp->f_data;
- if (so->so_proto != pffindtype(AF_LOCAL, SOCK_STREAM))
+ if (so->so_proto != pffindtype(AF_LOCAL, SOCK_STREAM)) {
+ FRELE(fp);
return (EOPNOTSUPP);
- FREF(fp);
+ }
m = m_getclr(M_WAIT, MT_SONAME);
if (m == NULL) {
error = ENOBUFS;
@@ -1146,5 +1145,7 @@ getsock(struct filedesc *fdp, int fdes, struct file **fpp)
if (fp->f_type != DTYPE_SOCKET)
return (ENOTSOCK);
*fpp = fp;
+ FREF(fp);
+
return (0);
}
diff --git a/sys/miscfs/portal/portal_vfsops.c b/sys/miscfs/portal/portal_vfsops.c
index 3fe99184349..4c43fb9489a 100644
--- a/sys/miscfs/portal/portal_vfsops.c
+++ b/sys/miscfs/portal/portal_vfsops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: portal_vfsops.c,v 1.13 2002/03/14 01:27:08 millert Exp $ */
+/* $OpenBSD: portal_vfsops.c,v 1.14 2002/08/23 22:21:44 art Exp $ */
/* $NetBSD: portal_vfsops.c,v 1.14 1996/02/09 22:40:41 christos Exp $ */
/*
@@ -105,10 +105,10 @@ portal_mount(mp, path, data, ndp, p)
if ((error = getsock(p->p_fd, args.pa_socket, &fp)) != 0)
return (error);
so = (struct socket *) fp->f_data;
- if (so->so_proto->pr_domain->dom_family != AF_UNIX)
+ if (so->so_proto->pr_domain->dom_family != AF_UNIX) {
+ FRELE(fp);
return (ESOCKTNOSUPPORT);
-
- FREF(fp);
+ }
error = getnewvnode(VT_PORTAL, mp, portal_vnodeop_p, &rvp); /* XXX */
if (error) {
diff --git a/sys/nfs/nfs_syscalls.c b/sys/nfs/nfs_syscalls.c
index aadac408ce4..9360e2c18e5 100644
--- a/sys/nfs/nfs_syscalls.c
+++ b/sys/nfs/nfs_syscalls.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nfs_syscalls.c,v 1.33 2002/07/24 23:32:11 nordin Exp $ */
+/* $OpenBSD: nfs_syscalls.c,v 1.34 2002/08/23 22:21:44 art Exp $ */
/* $NetBSD: nfs_syscalls.c,v 1.19 1996/02/18 11:53:52 fvdl Exp $ */
/*
@@ -286,7 +286,6 @@ sys_nfssvc(p, v, retval)
error = getsock(p->p_fd, nfsdarg.sock, &fp);
if (error)
return (error);
- FREF(fp);
/*
* Get the client address for connected sockets.
*/