diff --git a/sys/kern/kern_subr.c b/sys/kern/kern_subr.c index e2c9efea7be8..1040aba81dce 100644 --- a/sys/kern/kern_subr.c +++ b/sys/kern/kern_subr.c @@ -485,39 +485,39 @@ copyinstrfrom(const void * __restrict src, void * __restrict dst, size_t len, } int -iov_to_uio(struct iovec *iovp, u_int iovcnt, struct uio *auio) +iov_to_uio(struct iovec *iovp, u_int iovcnt, struct uio *uio) { - int error = 0, i; + struct iovec *iov; u_int iovlen; - struct iovec *iov = NULL; + int error, i; - /* note: can't use iovlen until iovcnt is validated */ - iovlen = iovcnt * sizeof (struct iovec); - if (iovcnt > UIO_MAXIOV) { - error = EINVAL; - goto done; - } - MALLOC(iov, struct iovec *, iovlen, M_IOV, M_WAITOK); - auio->uio_iov = iov; - auio->uio_iovcnt = iovcnt; - auio->uio_segflg = UIO_USERSPACE; - auio->uio_offset = -1; - if ((error = copyin(iovp, iov, iovlen))) - goto done; - auio->uio_resid = 0; - for (i = 0; i < iovcnt; i++) { - if (iov->iov_len > INT_MAX - auio->uio_resid) { - error = EINVAL; - goto done; - } - auio->uio_resid += iov->iov_len; - iov++; - } + /* note: can't use iovlen until iovcnt is validated */ + iovlen = iovcnt * sizeof (struct iovec); + if (iovcnt > UIO_MAXIOV) { + error = EINVAL; + goto done; + } + MALLOC(iov, struct iovec *, iovlen, M_IOV, M_WAITOK); + uio->uio_iov = iov; + uio->uio_iovcnt = iovcnt; + uio->uio_segflg = UIO_USERSPACE; + uio->uio_offset = -1; + if ((error = copyin(iovp, iov, iovlen))) + goto done; + uio->uio_resid = 0; + for (i = 0; i < iovcnt; i++) { + if (iov->iov_len > INT_MAX - uio->uio_resid) { + error = EINVAL; + goto done; + } + uio->uio_resid += iov->iov_len; + iov++; + } done: - if (error && auio->uio_iov) { - FREE(auio->uio_iov, M_IOV); - auio->uio_iov = NULL; + if (error && uio->uio_iov) { + FREE(uio->uio_iov, M_IOV); + uio->uio_iov = NULL; } return (error); diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c index 4a53f175cf72..d36f9fbe8ff8 100644 --- a/sys/kern/uipc_mbuf.c +++ b/sys/kern/uipc_mbuf.c @@ -1041,22 +1041,17 @@ m_uiotombuf(struct uio *uio, int how, int len) total = min(uio->uio_resid, len); else total = uio->uio_resid; - if (total > MHLEN) m_final = m_getcl(how, MT_DATA, M_PKTHDR); else m_final = m_gethdr(how, MT_DATA); - if (m_final == NULL) goto nospace; - m_new = m_final; - while (progress < total) { length = total - progress; if (length > MCLBYTES) length = MCLBYTES; - if (m_new == NULL) { if (length > MLEN) m_new = m_getcl(how, MT_DATA, 0); @@ -1065,7 +1060,6 @@ m_uiotombuf(struct uio *uio, int how, int len) if (m_new == NULL) goto nospace; } - error = uiomove(mtod(m_new, void *), length, uio); if (error) goto nospace;