summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorDoug Hogan <doug@cvs.openbsd.org>2014-12-09 06:58:30 +0000
committerDoug Hogan <doug@cvs.openbsd.org>2014-12-09 06:58:30 +0000
commitad90d9845d96f21749e3776b0296938c6d60ca9a (patch)
treeca999709d208d683272d9911f2706d59a203748f /sys/arch
parent7ac588b8eb1d276029001886214facee144b2fc5 (diff)
Replace some malloc(n*size,...) calls with mallocarray().
ok tedu@ deraadt@
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/alpha/dev/sgmap_common.c4
-rw-r--r--sys/arch/alpha/dev/shared_intr.c4
-rw-r--r--sys/arch/amd64/amd64/amd64_mem.c4
-rw-r--r--sys/arch/amd64/amd64/est.c6
-rw-r--r--sys/arch/amd64/amd64/ioapic.c4
-rw-r--r--sys/arch/amd64/amd64/mpbios.c6
-rw-r--r--sys/arch/amd64/amd64/via.c4
-rw-r--r--sys/arch/arm/arm/pmap.c4
-rw-r--r--sys/arch/hppa/dev/apic.c4
-rw-r--r--sys/arch/hppa64/dev/apic.c4
-rw-r--r--sys/arch/hppa64/hppa64/autoconf.c4
-rw-r--r--sys/arch/i386/i386/est.c6
-rw-r--r--sys/arch/i386/i386/i686_mem.c4
-rw-r--r--sys/arch/i386/i386/ioapic.c4
-rw-r--r--sys/arch/i386/i386/mpbios.c6
-rw-r--r--sys/arch/i386/i386/sys_machdep.c6
-rw-r--r--sys/arch/i386/i386/via.c4
-rw-r--r--sys/arch/i386/pci/glxsb.c5
-rw-r--r--sys/arch/octeon/dev/cn30xxgmx.c6
-rw-r--r--sys/arch/sgi/gio/grtwo.c4
-rw-r--r--sys/arch/sparc64/dev/pyro.c6
-rw-r--r--sys/arch/sparc64/dev/sbus.c5
-rw-r--r--sys/arch/sparc64/dev/vdsp.c8
-rw-r--r--sys/arch/sparc64/dev/vpci.c6
24 files changed, 60 insertions, 58 deletions
diff --git a/sys/arch/alpha/dev/sgmap_common.c b/sys/arch/alpha/dev/sgmap_common.c
index af751a93b10..c67150e81bd 100644
--- a/sys/arch/alpha/dev/sgmap_common.c
+++ b/sys/arch/alpha/dev/sgmap_common.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sgmap_common.c,v 1.13 2014/07/12 18:44:40 tedu Exp $ */
+/* $OpenBSD: sgmap_common.c,v 1.14 2014/12/09 06:58:28 doug Exp $ */
/* $NetBSD: sgmap_common.c,v 1.13 2000/06/29 09:02:57 mrg Exp $ */
/*-
@@ -148,7 +148,7 @@ alpha_sgmap_dmamap_setup(map, nsegments, flags)
int nsegments;
int flags;
{
- map->_dm_cookie = malloc(nsegments * sizeof(struct extent_region),
+ map->_dm_cookie = mallocarray(nsegments, sizeof(struct extent_region),
M_DEVBUF, (flags & BUS_DMA_NOWAIT) ? M_NOWAIT : M_WAITOK);
return (map->_dm_cookie == NULL);
}
diff --git a/sys/arch/alpha/dev/shared_intr.c b/sys/arch/alpha/dev/shared_intr.c
index c8ef5c2256c..2f1066fdd75 100644
--- a/sys/arch/alpha/dev/shared_intr.c
+++ b/sys/arch/alpha/dev/shared_intr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: shared_intr.c,v 1.19 2014/07/12 18:44:40 tedu Exp $ */
+/* $OpenBSD: shared_intr.c,v 1.20 2014/12/09 06:58:28 doug Exp $ */
/* $NetBSD: shared_intr.c,v 1.13 2000/03/19 01:46:18 thorpej Exp $ */
/*
@@ -70,7 +70,7 @@ alpha_shared_intr_alloc(n)
struct alpha_shared_intr *intr;
unsigned int i;
- intr = malloc(n * sizeof (struct alpha_shared_intr), M_DEVBUF,
+ intr = mallocarray(n, sizeof(struct alpha_shared_intr), M_DEVBUF,
cold ? M_NOWAIT : M_WAITOK);
if (intr == NULL)
panic("alpha_shared_intr_alloc: couldn't malloc intr");
diff --git a/sys/arch/amd64/amd64/amd64_mem.c b/sys/arch/amd64/amd64/amd64_mem.c
index ce0fd6d7727..c84dad299e5 100644
--- a/sys/arch/amd64/amd64/amd64_mem.c
+++ b/sys/arch/amd64/amd64/amd64_mem.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: amd64_mem.c,v 1.8 2014/07/13 12:11:01 jasper Exp $ */
+/* $OpenBSD: amd64_mem.c,v 1.9 2014/12/09 06:58:28 doug Exp $ */
/*
* Copyright (c) 1999 Michael Smith <msmith@freebsd.org>
* All rights reserved.
@@ -551,7 +551,7 @@ mrinit(struct mem_range_softc *sc)
printf("\n");
- sc->mr_desc = malloc(nmdesc * sizeof(struct mem_range_desc),
+ sc->mr_desc = mallocarray(nmdesc, sizeof(struct mem_range_desc),
M_MEMDESC, M_WAITOK|M_ZERO);
sc->mr_ndesc = nmdesc;
diff --git a/sys/arch/amd64/amd64/est.c b/sys/arch/amd64/amd64/est.c
index cea7696e189..944f75449ac 100644
--- a/sys/arch/amd64/amd64/est.c
+++ b/sys/arch/amd64/amd64/est.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: est.c,v 1.34 2014/09/14 14:17:23 jsg Exp $ */
+/* $OpenBSD: est.c,v 1.35 2014/12/09 06:58:28 doug Exp $ */
/*
* Copyright (c) 2003 Michael Eriksson.
* All rights reserved.
@@ -238,7 +238,7 @@ est_acpi_init()
== NULL)
goto nolist;
- if ((acpilist->table = malloc(sizeof(struct est_op) * nstates,
+ if ((acpilist->table = mallocarray(nstates, sizeof(struct est_op),
M_DEVBUF, M_NOWAIT)) == NULL)
goto notable;
@@ -278,7 +278,7 @@ est_acpi_pss_changed(struct acpicpu_pss *pss, int npss)
return;
}
- if ((acpilist->table = malloc(sizeof(struct est_op) * npss,
+ if ((acpilist->table = mallocarray(npss, sizeof(struct est_op),
M_DEVBUF, M_NOWAIT)) == NULL) {
printf("est_acpi_pss_changed: cannot allocate memory for new "
"operating points");
diff --git a/sys/arch/amd64/amd64/ioapic.c b/sys/arch/amd64/amd64/ioapic.c
index 3815c2f2021..c18a1036cb5 100644
--- a/sys/arch/amd64/amd64/ioapic.c
+++ b/sys/arch/amd64/amd64/ioapic.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ioapic.c,v 1.21 2014/11/22 18:55:20 deraadt Exp $ */
+/* $OpenBSD: ioapic.c,v 1.22 2014/12/09 06:58:28 doug Exp $ */
/* $NetBSD: ioapic.c,v 1.6 2003/05/15 13:30:31 fvdl Exp $ */
/*-
@@ -342,7 +342,7 @@ ioapic_attach(struct device *parent, struct device *self, void *aux)
apic_id = (ioapic_read(sc, IOAPIC_ID) & IOAPIC_ID_MASK) >>
IOAPIC_ID_SHIFT;
- sc->sc_pins = malloc(sizeof(struct ioapic_pin) * sc->sc_apic_sz,
+ sc->sc_pins = mallocarray(sc->sc_apic_sz, sizeof(struct ioapic_pin),
M_DEVBUF, M_WAITOK);
for (i = 0; i < sc->sc_apic_sz; i++) {
diff --git a/sys/arch/amd64/amd64/mpbios.c b/sys/arch/amd64/amd64/mpbios.c
index 614dbbec79e..5c083546a10 100644
--- a/sys/arch/amd64/amd64/mpbios.c
+++ b/sys/arch/amd64/amd64/mpbios.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mpbios.c,v 1.23 2014/11/16 12:30:56 deraadt Exp $ */
+/* $OpenBSD: mpbios.c,v 1.24 2014/12/09 06:58:28 doug Exp $ */
/* $NetBSD: mpbios.c,v 1.7 2003/05/15 16:32:50 fvdl Exp $ */
/*-
@@ -601,9 +601,9 @@ mpbios_scan(struct device *self)
position += mp_conf[type].length;
}
- mp_busses = malloc(sizeof(struct mp_bus) * mp_nbusses,
+ mp_busses = mallocarray(mp_nbusses, sizeof(struct mp_bus),
M_DEVBUF, M_NOWAIT|M_ZERO);
- mp_intrs = malloc(sizeof(struct mp_intr_map) * intr_cnt,
+ mp_intrs = mallocarray(intr_cnt, sizeof(struct mp_intr_map),
M_DEVBUF, M_NOWAIT);
/* re-walk the table, recording info of interest */
diff --git a/sys/arch/amd64/amd64/via.c b/sys/arch/amd64/amd64/via.c
index d80f5cd6613..ca303873c82 100644
--- a/sys/arch/amd64/amd64/via.c
+++ b/sys/arch/amd64/amd64/via.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: via.c,v 1.17 2014/09/14 14:17:23 jsg Exp $ */
+/* $OpenBSD: via.c,v 1.18 2014/12/09 06:58:28 doug Exp $ */
/* $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $ */
/*-
@@ -155,7 +155,7 @@ viac3_crypto_newsession(u_int32_t *sidp, struct cryptoini *cri)
if (ses == NULL) {
sesn = sc->sc_nsessions;
- ses = malloc((sesn + 1) * sizeof(*ses), M_DEVBUF,
+ ses = mallocarray(sesn + 1, sizeof(*ses), M_DEVBUF,
M_NOWAIT);
if (ses == NULL)
return (ENOMEM);
diff --git a/sys/arch/arm/arm/pmap.c b/sys/arch/arm/arm/pmap.c
index 27f486cfb7a..ce6f1f13777 100644
--- a/sys/arch/arm/arm/pmap.c
+++ b/sys/arch/arm/arm/pmap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pmap.c,v 1.48 2014/11/16 12:30:56 deraadt Exp $ */
+/* $OpenBSD: pmap.c,v 1.49 2014/12/09 06:58:28 doug Exp $ */
/* $NetBSD: pmap.c,v 1.147 2004/01/18 13:03:50 scw Exp $ */
/*
@@ -4133,7 +4133,7 @@ pmap_postinit(void)
needed = (maxprocess - 1) / PMAP_DOMAINS;
- l1 = malloc(sizeof(*l1) * needed, M_VMPMAP, M_WAITOK);
+ l1 = mallocarray(needed, sizeof(*l1), M_VMPMAP, M_WAITOK);
for (loop = 0; loop < needed; loop++, l1++) {
/* Allocate a L1 page table */
diff --git a/sys/arch/hppa/dev/apic.c b/sys/arch/hppa/dev/apic.c
index 475517a2145..d287d182a16 100644
--- a/sys/arch/hppa/dev/apic.c
+++ b/sys/arch/hppa/dev/apic.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: apic.c,v 1.15 2014/07/12 18:44:41 tedu Exp $ */
+/* $OpenBSD: apic.c,v 1.16 2014/12/09 06:58:28 doug Exp $ */
/*
* Copyright (c) 2005 Michael Shalayeff
@@ -107,7 +107,7 @@ apic_attach(struct elroy_softc *sc)
printf(" APIC ver %x, %d pins",
data & APIC_VERSION_MASK, sc->sc_nints);
- sc->sc_irq = malloc(sc->sc_nints * sizeof(int), M_DEVBUF,
+ sc->sc_irq = mallocarray(sc->sc_nints, sizeof(int), M_DEVBUF,
M_NOWAIT | M_ZERO);
if (sc->sc_irq == NULL)
panic("apic_attach: cannot allocate irq table");
diff --git a/sys/arch/hppa64/dev/apic.c b/sys/arch/hppa64/dev/apic.c
index ea6ec4727cd..be4410f3671 100644
--- a/sys/arch/hppa64/dev/apic.c
+++ b/sys/arch/hppa64/dev/apic.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: apic.c,v 1.7 2014/07/12 18:44:41 tedu Exp $ */
+/* $OpenBSD: apic.c,v 1.8 2014/12/09 06:58:28 doug Exp $ */
/*
* Copyright (c) 2005 Michael Shalayeff
@@ -109,7 +109,7 @@ apic_attach(struct elroy_softc *sc)
printf(" APIC ver %x, %d pins",
data & APIC_VERSION_MASK, sc->sc_nints);
- sc->sc_irq = malloc(sc->sc_nints * sizeof(int), M_DEVBUF,
+ sc->sc_irq = mallocarray(sc->sc_nints, sizeof(int), M_DEVBUF,
M_NOWAIT | M_ZERO);
if (sc->sc_irq == NULL)
panic("apic_attach: cannot allocate irq table");
diff --git a/sys/arch/hppa64/hppa64/autoconf.c b/sys/arch/hppa64/hppa64/autoconf.c
index 0df825000b6..395705d02cd 100644
--- a/sys/arch/hppa64/hppa64/autoconf.c
+++ b/sys/arch/hppa64/hppa64/autoconf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: autoconf.c,v 1.22 2014/10/12 20:39:46 miod Exp $ */
+/* $OpenBSD: autoconf.c,v 1.23 2014/12/09 06:58:28 doug Exp $ */
/*
* Copyright (c) 1998-2005 Michael Shalayeff
@@ -382,7 +382,7 @@ printf("num %d ", pdc_pat_io_num.num);
return (NULL);
}
- if (!(rt = malloc(num * sizeof(*rt), M_DEVBUF, M_NOWAIT)))
+ if (!(rt = mallocarray(num, sizeof(*rt), M_DEVBUF, M_NOWAIT)))
return (NULL);
if (cell >= 0) {
diff --git a/sys/arch/i386/i386/est.c b/sys/arch/i386/i386/est.c
index 927be477185..b0d79efb15a 100644
--- a/sys/arch/i386/i386/est.c
+++ b/sys/arch/i386/i386/est.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: est.c,v 1.44 2014/09/14 14:17:23 jsg Exp $ */
+/* $OpenBSD: est.c,v 1.45 2014/12/09 06:58:28 doug Exp $ */
/*
* Copyright (c) 2003 Michael Eriksson.
* All rights reserved.
@@ -981,7 +981,7 @@ est_acpi_init()
== NULL)
goto nolist;
- if ((acpilist->table = malloc(sizeof(struct est_op) * nstates,
+ if ((acpilist->table = mallocarray(nstates, sizeof(struct est_op),
M_DEVBUF, M_NOWAIT)) == NULL)
goto notable;
@@ -1021,7 +1021,7 @@ est_acpi_pss_changed(struct acpicpu_pss *pss, int npss)
return;
}
- if ((acpilist->table = malloc(sizeof(struct est_op) * npss,
+ if ((acpilist->table = mallocarray(npss, sizeof(struct est_op),
M_DEVBUF, M_NOWAIT)) == NULL) {
printf("est_acpi_pss_changed: cannot allocate memory for new "
"operating points");
diff --git a/sys/arch/i386/i386/i686_mem.c b/sys/arch/i386/i386/i686_mem.c
index 0a0f4c07e42..3f7cbb531be 100644
--- a/sys/arch/i386/i386/i686_mem.c
+++ b/sys/arch/i386/i386/i686_mem.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: i686_mem.c,v 1.16 2014/07/13 12:11:01 jasper Exp $ */
+/* $OpenBSD: i686_mem.c,v 1.17 2014/12/09 06:58:28 doug Exp $ */
/*
* Copyright (c) 1999 Michael Smith <msmith@freebsd.org>
* All rights reserved.
@@ -551,7 +551,7 @@ mrinit(struct mem_range_softc *sc)
printf("\n");
- sc->mr_desc = malloc(nmdesc * sizeof(struct mem_range_desc),
+ sc->mr_desc = mallocarray(nmdesc, sizeof(struct mem_range_desc),
M_MEMDESC, M_WAITOK|M_ZERO);
sc->mr_ndesc = nmdesc;
diff --git a/sys/arch/i386/i386/ioapic.c b/sys/arch/i386/i386/ioapic.c
index 803e44a2677..3f51ed96645 100644
--- a/sys/arch/i386/i386/ioapic.c
+++ b/sys/arch/i386/i386/ioapic.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ioapic.c,v 1.33 2014/11/22 18:55:20 deraadt Exp $ */
+/* $OpenBSD: ioapic.c,v 1.34 2014/12/09 06:58:28 doug Exp $ */
/* $NetBSD: ioapic.c,v 1.7 2003/07/14 22:32:40 lukem Exp $ */
/*-
@@ -336,7 +336,7 @@ ioapic_attach(struct device *parent, struct device *self, void *aux)
apic_id = (ioapic_read(sc, IOAPIC_ID) & IOAPIC_ID_MASK) >>
IOAPIC_ID_SHIFT;
- sc->sc_pins = malloc(sizeof(struct ioapic_pin) * sc->sc_apic_sz,
+ sc->sc_pins = mallocarray(sc->sc_apic_sz, sizeof(struct ioapic_pin),
M_DEVBUF, M_WAITOK);
for (i = 0; i < sc->sc_apic_sz; i++) {
diff --git a/sys/arch/i386/i386/mpbios.c b/sys/arch/i386/i386/mpbios.c
index 4347c96ceb5..915dc47231e 100644
--- a/sys/arch/i386/i386/mpbios.c
+++ b/sys/arch/i386/i386/mpbios.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mpbios.c,v 1.36 2014/11/16 12:30:57 deraadt Exp $ */
+/* $OpenBSD: mpbios.c,v 1.37 2014/12/09 06:58:28 doug Exp $ */
/* $NetBSD: mpbios.c,v 1.2 2002/10/01 12:56:57 fvdl Exp $ */
/*-
@@ -637,9 +637,9 @@ mpbios_scan(struct device *self)
}
}
- mp_busses = malloc(sizeof(struct mp_bus) * mp_nbusses,
+ mp_busses = mallocarray(mp_nbusses, sizeof(struct mp_bus),
M_DEVBUF, M_NOWAIT|M_ZERO);
- mp_intrs = malloc(sizeof(struct mp_intr_map) * intr_cnt,
+ mp_intrs = mallocarray(intr_cnt, sizeof(struct mp_intr_map),
M_DEVBUF, M_NOWAIT);
/* re-walk the table, recording info of interest */
diff --git a/sys/arch/i386/i386/sys_machdep.c b/sys/arch/i386/i386/sys_machdep.c
index 40c22249d9f..105dca08ca3 100644
--- a/sys/arch/i386/i386/sys_machdep.c
+++ b/sys/arch/i386/i386/sys_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sys_machdep.c,v 1.33 2014/12/02 18:13:10 tedu Exp $ */
+/* $OpenBSD: sys_machdep.c,v 1.34 2014/12/09 06:58:28 doug Exp $ */
/* $NetBSD: sys_machdep.c,v 1.28 1996/05/03 19:42:29 christos Exp $ */
/*-
@@ -112,7 +112,7 @@ i386_get_ldt(struct proc *p, void *args, register_t *retval)
ua.start + ua.num > 8192)
return (EINVAL);
- cp = malloc(ua.num * sizeof(union descriptor), M_TEMP, M_WAITOK);
+ cp = mallocarray(ua.num, sizeof(union descriptor), M_TEMP, M_WAITOK);
if (pmap->pm_flags & PMF_USER_LDT) {
nldt = pmap->pm_ldt_len;
@@ -168,7 +168,7 @@ i386_set_ldt(struct proc *p, void *args, register_t *retval)
ua.start + ua.num > 8192)
return (EINVAL);
- descv = malloc(sizeof (*descv) * ua.num, M_TEMP, M_NOWAIT);
+ descv = mallocarray(ua.num, sizeof(*descv), M_TEMP, M_NOWAIT);
if (descv == NULL)
return (ENOMEM);
diff --git a/sys/arch/i386/i386/via.c b/sys/arch/i386/i386/via.c
index f7a6194fe71..06ddef156d4 100644
--- a/sys/arch/i386/i386/via.c
+++ b/sys/arch/i386/i386/via.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: via.c,v 1.33 2014/09/14 14:17:23 jsg Exp $ */
+/* $OpenBSD: via.c,v 1.34 2014/12/09 06:58:28 doug Exp $ */
/* $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $ */
/*-
@@ -157,7 +157,7 @@ viac3_crypto_newsession(u_int32_t *sidp, struct cryptoini *cri)
if (ses == NULL) {
sesn = sc->sc_nsessions;
- ses = malloc((sesn + 1) * sizeof(*ses), M_DEVBUF,
+ ses = mallocarray(sesn + 1, sizeof(*ses), M_DEVBUF,
M_NOWAIT);
if (ses == NULL)
return (ENOMEM);
diff --git a/sys/arch/i386/pci/glxsb.c b/sys/arch/i386/pci/glxsb.c
index d7cf94a622d..b1c1a1f3ea6 100644
--- a/sys/arch/i386/pci/glxsb.c
+++ b/sys/arch/i386/pci/glxsb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: glxsb.c,v 1.28 2014/07/12 18:44:42 tedu Exp $ */
+/* $OpenBSD: glxsb.c,v 1.29 2014/12/09 06:58:28 doug Exp $ */
/*
* Copyright (c) 2006 Tom Cosgrove <tom@openbsd.org>
@@ -377,7 +377,8 @@ glxsb_crypto_newsession(uint32_t *sidp, struct cryptoini *cri)
if (ses == NULL) {
sesn = sc->sc_nsessions;
- ses = malloc((sesn + 1) * sizeof(*ses), M_DEVBUF, M_NOWAIT);
+ ses = mallocarray(sesn + 1, sizeof(*ses), M_DEVBUF,
+ M_NOWAIT);
if (ses == NULL)
return (ENOMEM);
if (sesn != 0) {
diff --git a/sys/arch/octeon/dev/cn30xxgmx.c b/sys/arch/octeon/dev/cn30xxgmx.c
index 3174222599a..c5d14749bfe 100644
--- a/sys/arch/octeon/dev/cn30xxgmx.c
+++ b/sys/arch/octeon/dev/cn30xxgmx.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cn30xxgmx.c,v 1.16 2014/08/11 19:00:50 miod Exp $ */
+/* $OpenBSD: cn30xxgmx.c,v 1.17 2014/12/09 06:58:28 doug Exp $ */
/*
* Copyright (c) 2007 Internet Initiative Japan, Inc.
@@ -215,8 +215,8 @@ cn30xxgmx_attach(struct device *parent, struct device *self, void *aux)
cn30xxgmx_init(sc);
- sc->sc_ports = malloc(sizeof(*sc->sc_ports) * sc->sc_nports, M_DEVBUF,
- M_NOWAIT | M_ZERO);
+ sc->sc_ports = mallocarray(sc->sc_nports, sizeof(*sc->sc_ports),
+ M_DEVBUF, M_NOWAIT | M_ZERO);
for (i = 0; i < sc->sc_nports; i++) {
port_sc = &sc->sc_ports[i];
diff --git a/sys/arch/sgi/gio/grtwo.c b/sys/arch/sgi/gio/grtwo.c
index 4727dd1f6af..fd42e7eb2cb 100644
--- a/sys/arch/sgi/gio/grtwo.c
+++ b/sys/arch/sgi/gio/grtwo.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: grtwo.c,v 1.10 2014/07/12 18:44:42 tedu Exp $ */
+/* $OpenBSD: grtwo.c,v 1.11 2014/12/09 06:58:29 doug Exp $ */
/* $NetBSD: grtwo.c,v 1.11 2009/11/22 19:09:15 mbalmer Exp $ */
/*
@@ -509,7 +509,7 @@ grtwo_init_screen(struct grtwo_devconfig *dc, int malloc_flags)
* be able to paint an inverted cursor.
*/
if (dc->dc_bs == NULL) {
- dc->dc_bs = malloc(ri->ri_rows * ri->ri_cols *
+ dc->dc_bs = mallocarray(ri->ri_rows, ri->ri_cols *
sizeof(struct wsdisplay_charcell), M_DEVBUF,
malloc_flags | M_ZERO);
if (dc->dc_bs == NULL)
diff --git a/sys/arch/sparc64/dev/pyro.c b/sys/arch/sparc64/dev/pyro.c
index d79cb427d4e..668ee637603 100644
--- a/sys/arch/sparc64/dev/pyro.c
+++ b/sys/arch/sparc64/dev/pyro.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pyro.c,v 1.27 2014/07/12 18:44:43 tedu Exp $ */
+/* $OpenBSD: pyro.c,v 1.28 2014/12/09 06:58:29 doug Exp $ */
/*
* Copyright (c) 2002 Jason L. Wright (jason@thought.net)
@@ -304,8 +304,8 @@ pyro_init_msi(struct pyro_softc *sc, struct pyro_pbm *pbm)
pbm->pp_msiaddr |= ((bus_addr_t)msi_addr_range[0]) << 32;
msis = getpropint(sc->sc_node, "#msi", 256);
- pbm->pp_msi = malloc(msis * sizeof(*pbm->pp_msi),
- M_DEVBUF, M_NOWAIT | M_ZERO);
+ pbm->pp_msi = mallocarray(msis, sizeof(*pbm->pp_msi), M_DEVBUF,
+ M_NOWAIT | M_ZERO);
if (pbm->pp_msi == NULL)
return;
diff --git a/sys/arch/sparc64/dev/sbus.c b/sys/arch/sparc64/dev/sbus.c
index c4efd70b7cc..098e85381a3 100644
--- a/sys/arch/sparc64/dev/sbus.c
+++ b/sys/arch/sparc64/dev/sbus.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sbus.c,v 1.42 2014/07/12 20:18:09 uebayasi Exp $ */
+/* $OpenBSD: sbus.c,v 1.43 2014/12/09 06:58:29 doug Exp $ */
/* $NetBSD: sbus.c,v 1.46 2001/10/07 20:30:41 eeh Exp $ */
/*-
@@ -600,7 +600,8 @@ sbus_get_intr(struct sbus_softc *sc, int node, struct sbus_intr **ipp, int *np,
pri = INTLEVENCODE(2);
/* Change format to an `struct sbus_intr' array */
- ip = malloc(*np * sizeof(struct sbus_intr), M_DEVBUF, M_NOWAIT);
+ ip = mallocarray(*np, sizeof(struct sbus_intr), M_DEVBUF,
+ M_NOWAIT);
if (ip == NULL)
return (ENOMEM);
diff --git a/sys/arch/sparc64/dev/vdsp.c b/sys/arch/sparc64/dev/vdsp.c
index 3813138e74c..9e394d8ffca 100644
--- a/sys/arch/sparc64/dev/vdsp.c
+++ b/sys/arch/sparc64/dev/vdsp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vdsp.c,v 1.32 2014/09/29 19:34:23 kettenis Exp $ */
+/* $OpenBSD: vdsp.c,v 1.33 2014/12/09 06:58:29 doug Exp $ */
/*
* Copyright (c) 2009, 2011, 2014 Mark Kettenis
*
@@ -1080,10 +1080,10 @@ vdsp_alloc(void *arg1, void *arg2)
KASSERT(sc->sc_num_descriptors <= VDSK_MAX_DESCRIPTORS);
KASSERT(sc->sc_descriptor_size <= VDSK_MAX_DESCRIPTOR_SIZE);
- sc->sc_vd = malloc(sc->sc_num_descriptors * sc->sc_descriptor_size,
- M_DEVBUF, M_WAITOK);
- sc->sc_vd_task = malloc(sc->sc_num_descriptors * sizeof(struct task),
+ sc->sc_vd = mallocarray(sc->sc_num_descriptors, sc->sc_descriptor_size,
M_DEVBUF, M_WAITOK);
+ sc->sc_vd_task = mallocarray(sc->sc_num_descriptors,
+ sizeof(struct task), M_DEVBUF, M_WAITOK);
bzero(&dr, sizeof(dr));
dr.tag.type = VIO_TYPE_CTRL;
diff --git a/sys/arch/sparc64/dev/vpci.c b/sys/arch/sparc64/dev/vpci.c
index 6e86ec1b63c..0633a7cfded 100644
--- a/sys/arch/sparc64/dev/vpci.c
+++ b/sys/arch/sparc64/dev/vpci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vpci.c,v 1.17 2014/11/24 22:41:12 kettenis Exp $ */
+/* $OpenBSD: vpci.c,v 1.18 2014/12/09 06:58:29 doug Exp $ */
/*
* Copyright (c) 2008 Mark Kettenis <kettenis@openbsd.org>
*
@@ -241,8 +241,8 @@ vpci_init_msi(struct vpci_softc *sc, struct vpci_pbm *pbm)
pbm->vp_msiaddr |= ((bus_addr_t)msi_addr_range[0]) << 32;
msis = getpropint(sc->sc_node, "#msi", 256);
- pbm->vp_msi = malloc(msis * sizeof(*pbm->vp_msi),
- M_DEVBUF, M_NOWAIT | M_ZERO);
+ pbm->vp_msi = mallocarray(msis, sizeof(*pbm->vp_msi), M_DEVBUF,
+ M_NOWAIT | M_ZERO);
if (pbm->vp_msi == NULL)
return;