From fd459f1474747c82eeb7be3f8057e81cd0a004bc Mon Sep 17 00:00:00 2001 From: ed Date: Sun, 7 Jan 2018 22:38:45 +0000 Subject: [PATCH] Use mallocarray(9) in CloudABI kernel code where possible. Submitted by: pfg@ --- sys/compat/cloudabi32/cloudabi32_sock.c | 4 ++-- sys/compat/cloudabi64/cloudabi64_sock.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/compat/cloudabi32/cloudabi32_sock.c b/sys/compat/cloudabi32/cloudabi32_sock.c index b4fa09ca1d42..97cb4478cf57 100644 --- a/sys/compat/cloudabi32/cloudabi32_sock.c +++ b/sys/compat/cloudabi32/cloudabi32_sock.c @@ -60,7 +60,7 @@ cloudabi32_sys_sock_recv(struct thread *td, /* Convert iovecs to native format. */ if (ri.ri_data_len > UIO_MAXIOV) return (EINVAL); - iov = malloc(ri.ri_data_len * sizeof(struct iovec), + iov = mallocarray(ri.ri_data_len, sizeof(struct iovec), M_SOCKET, M_WAITOK); user_iov = TO_PTR(ri.ri_data); for (i = 0; i < ri.ri_data_len; i++) { @@ -104,7 +104,7 @@ cloudabi32_sys_sock_send(struct thread *td, /* Convert iovecs to native format. */ if (si.si_data_len > UIO_MAXIOV) return (EINVAL); - iov = malloc(si.si_data_len * sizeof(struct iovec), + iov = mallocarray(si.si_data_len, sizeof(struct iovec), M_SOCKET, M_WAITOK); user_iov = TO_PTR(si.si_data); for (i = 0; i < si.si_data_len; i++) { diff --git a/sys/compat/cloudabi64/cloudabi64_sock.c b/sys/compat/cloudabi64/cloudabi64_sock.c index 482b6d8f67e9..001adada384a 100644 --- a/sys/compat/cloudabi64/cloudabi64_sock.c +++ b/sys/compat/cloudabi64/cloudabi64_sock.c @@ -60,7 +60,7 @@ cloudabi64_sys_sock_recv(struct thread *td, /* Convert iovecs to native format. */ if (ri.ri_data_len > UIO_MAXIOV) return (EINVAL); - iov = malloc(ri.ri_data_len * sizeof(struct iovec), + iov = mallocarray(ri.ri_data_len, sizeof(struct iovec), M_SOCKET, M_WAITOK); user_iov = TO_PTR(ri.ri_data); for (i = 0; i < ri.ri_data_len; i++) { @@ -104,7 +104,7 @@ cloudabi64_sys_sock_send(struct thread *td, /* Convert iovecs to native format. */ if (si.si_data_len > UIO_MAXIOV) return (EINVAL); - iov = malloc(si.si_data_len * sizeof(struct iovec), + iov = mallocarray(si.si_data_len, sizeof(struct iovec), M_SOCKET, M_WAITOK); user_iov = TO_PTR(si.si_data); for (i = 0; i < si.si_data_len; i++) {