diff options
Diffstat (limited to 'sys/kern/uipc_syscalls.c')
-rw-r--r-- | sys/kern/uipc_syscalls.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c index 147dcb789b9..879e8096c47 100644 --- a/sys/kern/uipc_syscalls.c +++ b/sys/kern/uipc_syscalls.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_syscalls.c,v 1.90 2014/07/12 18:43:32 tedu Exp $ */ +/* $OpenBSD: uipc_syscalls.c,v 1.91 2014/07/13 15:00:40 tedu Exp $ */ /* $NetBSD: uipc_syscalls.c,v 1.19 1996/02/09 19:00:48 christos Exp $ */ /* @@ -454,7 +454,7 @@ sys_sendmsg(struct proc *p, void *v, register_t *retval) error = sendit(p, SCARG(uap, s), &msg, SCARG(uap, flags), retval); done: if (iov != aiov) - free(iov, M_IOV, 0); + free(iov, M_IOV, sizeof(struct iovec) * msg.msg_iovlen); return (error); } @@ -470,6 +470,7 @@ sendit(struct proc *p, int s, struct msghdr *mp, int flags, register_t *retsize) int error; #ifdef KTRACE struct iovec *ktriov = NULL; + int iovlen = 0; #endif to = NULL; @@ -515,7 +516,7 @@ sendit(struct proc *p, int s, struct msghdr *mp, int flags, register_t *retsize) control = 0; #ifdef KTRACE if (KTRPOINT(p, KTR_GENIO)) { - int iovlen = auio.uio_iovcnt * sizeof (struct iovec); + iovlen = auio.uio_iovcnt * sizeof (struct iovec); ktriov = malloc(iovlen, M_TEMP, M_WAITOK); bcopy(auio.uio_iov, ktriov, iovlen); @@ -539,7 +540,7 @@ sendit(struct proc *p, int s, struct msghdr *mp, int flags, register_t *retsize) if (ktriov != NULL) { if (error == 0) ktrgenio(p, s, UIO_WRITE, ktriov, *retsize); - free(ktriov, M_TEMP, 0); + free(ktriov, M_TEMP, iovlen); } #endif bad: @@ -619,7 +620,7 @@ sys_recvmsg(struct proc *p, void *v, register_t *retval) } done: if (iov != aiov) - free(iov, M_IOV, 0); + free(iov, M_IOV, sizeof(struct iovec) * msg.msg_iovlen); return (error); } @@ -636,6 +637,7 @@ recvit(struct proc *p, int s, struct msghdr *mp, caddr_t namelenp, struct mbuf *from = NULL, *control = NULL; #ifdef KTRACE struct iovec *ktriov = NULL; + int iovlen = 0; #endif if ((error = getsock(p->p_fd, s, &fp)) != 0) @@ -658,7 +660,7 @@ recvit(struct proc *p, int s, struct msghdr *mp, caddr_t namelenp, } #ifdef KTRACE if (KTRPOINT(p, KTR_GENIO)) { - int iovlen = auio.uio_iovcnt * sizeof (struct iovec); + iovlen = auio.uio_iovcnt * sizeof (struct iovec); ktriov = malloc(iovlen, M_TEMP, M_WAITOK); bcopy(auio.uio_iov, ktriov, iovlen); @@ -678,7 +680,7 @@ recvit(struct proc *p, int s, struct msghdr *mp, caddr_t namelenp, if (ktriov != NULL) { if (error == 0) ktrgenio(p, s, UIO_READ, ktriov, len - auio.uio_resid); - free(ktriov, M_TEMP, 0); + free(ktriov, M_TEMP, iovlen); } #endif if (error) |