From 11b9c642fb4a954f16dc6bb176f7d7cdf6382c74 Mon Sep 17 00:00:00 2001 From: deraadt Date: Wed, 5 Apr 2017 22:45:21 +0000 Subject: [PATCH] 3 more mallocarray() uses --- sys/dev/usb/uaudio.c | 4 ++-- sys/dev/usb/usb_subr.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/sys/dev/usb/uaudio.c b/sys/dev/usb/uaudio.c index 592b8db607d..b8e92becf2c 100644 --- a/sys/dev/usb/uaudio.c +++ b/sys/dev/usb/uaudio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uaudio.c,v 1.124 2017/02/10 08:09:36 ratchov Exp $ */ +/* $OpenBSD: uaudio.c,v 1.125 2017/04/05 22:45:21 deraadt Exp $ */ /* $NetBSD: uaudio.c,v 1.90 2004/10/29 17:12:53 kent Exp $ */ /* @@ -1829,7 +1829,7 @@ uaudio_identify_ac(struct uaudio_softc *sc, const usb_config_descriptor_t *cdesc ibufend = ibuf + aclen; dp = (const usb_descriptor_t *)ibuf; ndps = 0; - iot = malloc(256 * sizeof(struct io_terminal), + iot = mallocarray(256, sizeof(struct io_terminal), M_TEMP, M_NOWAIT | M_ZERO); if (iot == NULL) { printf("%s: no memory\n", __func__); diff --git a/sys/dev/usb/usb_subr.c b/sys/dev/usb/usb_subr.c index ae330debbff..68afe2d2156 100644 --- a/sys/dev/usb/usb_subr.c +++ b/sys/dev/usb/usb_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: usb_subr.c,v 1.132 2017/03/26 15:31:15 deraadt Exp $ */ +/* $OpenBSD: usb_subr.c,v 1.133 2017/04/05 22:45:21 deraadt Exp $ */ /* $NetBSD: usb_subr.c,v 1.103 2003/01/10 11:19:13 augustss Exp $ */ /* $FreeBSD: src/sys/dev/usb/usb_subr.c,v 1.18 1999/11/17 22:33:47 n_hibma Exp $ */ @@ -890,7 +890,7 @@ usbd_probe_and_attach(struct device *parent, struct usbd_device *dev, int port, DPRINTF(("usbd_probe_and_attach trying device specific drivers\n")); dv = config_found(parent, &uaa, usbd_print); if (dv) { - dev->subdevs = malloc(2 * sizeof dv, M_USB, M_NOWAIT); + dev->subdevs = mallocarray(2, sizeof dv, M_USB, M_NOWAIT); if (dev->subdevs == NULL) { err = USBD_NOMEM; goto fail; @@ -988,7 +988,7 @@ generic: dv = config_found(parent, &uaa, usbd_print); if (dv != NULL) { if (dev->ndevs == 0) { - dev->subdevs = malloc(2 * sizeof dv, M_USB, M_NOWAIT); + dev->subdevs = mallocarray(2, sizeof dv, M_USB, M_NOWAIT); if (dev->subdevs == NULL) { err = USBD_NOMEM; goto fail; -- 2.20.1