summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorderaadt <deraadt@openbsd.org>2014-07-13 17:34:25 +0000
committerderaadt <deraadt@openbsd.org>2014-07-13 17:34:25 +0000
commit5f2418a7026722f36014aa9f68ea8cd60325f158 (patch)
treea10473a79733755c8e6af4fab6273f3bcce264d0
parent-N for SYNOPSIS and usage(), and some small changes to previous; (diff)
downloadwireguard-openbsd-5f2418a7026722f36014aa9f68ea8cd60325f158.tar.xz
wireguard-openbsd-5f2418a7026722f36014aa9f68ea8cd60325f158.zip
use mallocarray where arguments are multiplied; ok tedu
-rw-r--r--sys/scsi/ch.c7
-rw-r--r--sys/scsi/safte.c4
2 files changed, 6 insertions, 5 deletions
diff --git a/sys/scsi/ch.c b/sys/scsi/ch.c
index d00f1d0515c..818a0d0cbef 100644
--- a/sys/scsi/ch.c
+++ b/sys/scsi/ch.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ch.c,v 1.47 2014/07/12 18:50:25 tedu Exp $ */
+/* $OpenBSD: ch.c,v 1.48 2014/07/13 17:34:25 deraadt Exp $ */
/* $NetBSD: ch.c,v 1.26 1997/02/21 22:06:52 thorpej Exp $ */
/*
@@ -596,9 +596,10 @@ ch_usergetelemstatus(struct ch_softc *sc,
error = EINVAL;
goto done;
}
- udsize = avail * sizeof(struct changer_element_status);
- user_data = malloc(udsize, M_DEVBUF, M_WAITOK | M_ZERO);
+ user_data = mallocarray(avail, sizeof(struct changer_element_status),
+ M_DEVBUF, M_WAITOK | M_ZERO);
+ udsize = avail * sizeof(struct changer_element_status);
desc = (caddr_t)(pg_hdr + 1);
for (i = 0; i < avail; ++i) {
diff --git a/sys/scsi/safte.c b/sys/scsi/safte.c
index 5ac48e7fc61..ece1499d540 100644
--- a/sys/scsi/safte.c
+++ b/sys/scsi/safte.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: safte.c,v 1.49 2014/07/12 18:50:25 tedu Exp $ */
+/* $OpenBSD: safte.c,v 1.50 2014/07/13 17:34:25 deraadt Exp $ */
/*
* Copyright (c) 2005 David Gwynne <dlg@openbsd.org>
@@ -321,7 +321,7 @@ safte_read_config(struct safte_softc *sc)
sc->sc_nsensors = config->nfans + config->npwrsup + config->ntemps +
(config->doorlock ? 1 : 0) + (config->alarm ? 1 : 0);
- sc->sc_sensors = malloc(sc->sc_nsensors * sizeof(struct safte_sensor),
+ sc->sc_sensors = mallocarray(sc->sc_nsensors, sizeof(struct safte_sensor),
M_DEVBUF, M_NOWAIT | M_ZERO);
if (sc->sc_sensors == NULL) {
dma_free(sc->sc_encbuf, sc->sc_encbuflen);