summaryrefslogtreecommitdiff
path: root/sys/dev/ic
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/ic')
-rw-r--r--sys/dev/ic/ahci.c6
-rw-r--r--sys/dev/ic/aic79xx.c6
-rw-r--r--sys/dev/ic/aic7xxx.c6
-rw-r--r--sys/dev/ic/ami.c8
-rw-r--r--sys/dev/ic/ar5008.c4
-rw-r--r--sys/dev/ic/ar5xxx.c4
-rw-r--r--sys/dev/ic/ar9003.c5
-rw-r--r--sys/dev/ic/cac.c10
-rw-r--r--sys/dev/ic/ciss.c6
-rw-r--r--sys/dev/ic/lance.c6
-rw-r--r--sys/dev/ic/malo.c10
-rw-r--r--sys/dev/ic/mfi.c8
-rw-r--r--sys/dev/ic/mpi.c12
-rw-r--r--sys/dev/ic/nvme.c4
-rw-r--r--sys/dev/ic/oosiop.c4
-rw-r--r--sys/dev/ic/osiop.c4
-rw-r--r--sys/dev/ic/qla.c4
-rw-r--r--sys/dev/ic/qlw.c4
-rw-r--r--sys/dev/ic/rt2560.c10
-rw-r--r--sys/dev/ic/rt2661.c10
-rw-r--r--sys/dev/ic/rtw.c4
-rw-r--r--sys/dev/ic/sili.c6
-rw-r--r--sys/dev/ic/siop.c4
-rw-r--r--sys/dev/ic/vga.c11
-rw-r--r--sys/dev/ic/z8530tty.c6
25 files changed, 81 insertions, 81 deletions
diff --git a/sys/dev/ic/ahci.c b/sys/dev/ic/ahci.c
index 669ae5f0962..680dae6f7fb 100644
--- a/sys/dev/ic/ahci.c
+++ b/sys/dev/ic/ahci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ahci.c,v 1.15 2014/07/12 18:48:17 tedu Exp $ */
+/* $OpenBSD: ahci.c,v 1.16 2014/07/13 23:10:23 deraadt Exp $ */
/*
* Copyright (c) 2006 David Gwynne <dlg@openbsd.org>
@@ -527,8 +527,8 @@ ahci_port_alloc(struct ahci_softc *sc, u_int port)
}
/* Allocate a CCB for each command slot */
- ap->ap_ccbs = malloc(sizeof(struct ahci_ccb) * sc->sc_ncmds, M_DEVBUF,
- M_NOWAIT | M_ZERO);
+ ap->ap_ccbs = mallocarray(sc->sc_ncmds, sizeof(struct ahci_ccb),
+ M_DEVBUF, M_NOWAIT | M_ZERO);
if (ap->ap_ccbs == NULL) {
printf("%s: unable to allocate command list for port %d\n",
DEVNAME(sc), port);
diff --git a/sys/dev/ic/aic79xx.c b/sys/dev/ic/aic79xx.c
index 6fd07dd86cf..95c88722334 100644
--- a/sys/dev/ic/aic79xx.c
+++ b/sys/dev/ic/aic79xx.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: aic79xx.c,v 1.53 2014/07/12 18:48:17 tedu Exp $ */
+/* $OpenBSD: aic79xx.c,v 1.54 2014/07/13 23:10:23 deraadt Exp $ */
/*
* Copyright (c) 2004 Milos Urbanek, Kenneth R. Westerback & Marco Peereboom
@@ -6177,8 +6177,8 @@ ahd_init(struct ahd_softc *ahd)
AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK);
ahd->stack_size = ahd_probe_stack_size(ahd);
- ahd->saved_stack = malloc(ahd->stack_size * sizeof(uint16_t), M_DEVBUF,
- M_NOWAIT | M_ZERO);
+ ahd->saved_stack = mallocarray(ahd->stack_size, sizeof(uint16_t),
+ M_DEVBUF, M_NOWAIT | M_ZERO);
if (ahd->saved_stack == NULL)
return (ENOMEM);
diff --git a/sys/dev/ic/aic7xxx.c b/sys/dev/ic/aic7xxx.c
index 9d6874f1f09..723af0416fd 100644
--- a/sys/dev/ic/aic7xxx.c
+++ b/sys/dev/ic/aic7xxx.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: aic7xxx.c,v 1.87 2014/07/12 18:48:17 tedu Exp $ */
+/* $OpenBSD: aic7xxx.c,v 1.88 2014/07/13 23:10:23 deraadt Exp $ */
/* $NetBSD: aic7xxx.c,v 1.108 2003/11/02 11:07:44 wiz Exp $ */
/*
@@ -40,7 +40,7 @@
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGES.
*
- * $Id: aic7xxx.c,v 1.87 2014/07/12 18:48:17 tedu Exp $
+ * $Id: aic7xxx.c,v 1.88 2014/07/13 23:10:23 deraadt Exp $
*/
/*
* Ported from FreeBSD by Pascal Renauld, Network Storage Solutions, Inc. - April 2003
@@ -4235,7 +4235,7 @@ ahc_init_scbdata(struct ahc_softc *ahc)
SLIST_INIT(&scb_data->sg_maps);
/* Allocate SCB resources */
- scb_data->scbarray = malloc(sizeof(struct scb) * AHC_SCB_MAX_ALLOC,
+ scb_data->scbarray = mallocarray(AHC_SCB_MAX_ALLOC, sizeof(struct scb),
M_DEVBUF, M_NOWAIT | M_ZERO);
if (scb_data->scbarray == NULL)
return (ENOMEM);
diff --git a/sys/dev/ic/ami.c b/sys/dev/ic/ami.c
index f1e3ba6bde1..9ea85f29e2c 100644
--- a/sys/dev/ic/ami.c
+++ b/sys/dev/ic/ami.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ami.c,v 1.227 2014/07/12 18:48:17 tedu Exp $ */
+/* $OpenBSD: ami.c,v 1.228 2014/07/13 23:10:23 deraadt Exp $ */
/*
* Copyright (c) 2001 Michael Shalayeff
@@ -299,7 +299,7 @@ ami_alloc_ccbs(struct ami_softc *sc, int nccbs)
struct ami_ccbmem *ccbmem, *mem;
int i, error;
- sc->sc_ccbs = malloc(sizeof(struct ami_ccb) * nccbs,
+ sc->sc_ccbs = mallocarray(nccbs, sizeof(struct ami_ccb),
M_DEVBUF, M_NOWAIT);
if (sc->sc_ccbs == NULL) {
printf(": unable to allocate ccbs\n");
@@ -566,7 +566,7 @@ ami_attach(struct ami_softc *sc)
#endif
#endif
- rsc = malloc(sizeof(struct ami_rawsoftc) * sc->sc_channels,
+ rsc = mallocarray(sc->sc_channels, sizeof(struct ami_rawsoftc),
M_DEVBUF, M_NOWAIT|M_ZERO);
if (!rsc) {
printf("%s: no memory for raw interface\n", DEVNAME(sc));
@@ -2408,7 +2408,7 @@ ami_create_sensors(struct ami_softc *sc)
if (ssc == NULL)
return (1);
- sc->sc_sensors = malloc(sizeof(struct ksensor) * sc->sc_nunits,
+ sc->sc_sensors = mallocarray(sc->sc_nunits, sizeof(struct ksensor),
M_DEVBUF, M_WAITOK|M_CANFAIL|M_ZERO);
if (sc->sc_sensors == NULL)
return (1);
diff --git a/sys/dev/ic/ar5008.c b/sys/dev/ic/ar5008.c
index 0a55576527e..0cd073591c0 100644
--- a/sys/dev/ic/ar5008.c
+++ b/sys/dev/ic/ar5008.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ar5008.c,v 1.24 2014/07/12 18:48:17 tedu Exp $ */
+/* $OpenBSD: ar5008.c,v 1.25 2014/07/13 23:10:23 deraadt Exp $ */
/*-
* Copyright (c) 2009 Damien Bergamini <damien.bergamini@free.fr>
@@ -569,7 +569,7 @@ ar5008_rx_alloc(struct athn_softc *sc)
bus_size_t size;
int error, nsegs, i;
- rxq->bf = malloc(ATHN_NRXBUFS * sizeof(*bf), M_DEVBUF,
+ rxq->bf = mallocarray(ATHN_NRXBUFS, sizeof(*bf), M_DEVBUF,
M_NOWAIT | M_ZERO);
if (rxq->bf == NULL)
return (ENOMEM);
diff --git a/sys/dev/ic/ar5xxx.c b/sys/dev/ic/ar5xxx.c
index dd86d6cd50a..fe1af1ca4fc 100644
--- a/sys/dev/ic/ar5xxx.c
+++ b/sys/dev/ic/ar5xxx.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ar5xxx.c,v 1.57 2014/07/12 18:48:17 tedu Exp $ */
+/* $OpenBSD: ar5xxx.c,v 1.58 2014/07/13 23:10:23 deraadt Exp $ */
/*
* Copyright (c) 2004, 2005, 2006, 2007 Reyk Floeter <reyk@openbsd.org>
@@ -388,7 +388,7 @@ ath_hal_init_channels(struct ath_hal *hal, HAL_CHANNEL *channels,
u_int domain_5ghz, domain_2ghz;
HAL_CHANNEL *all_channels;
- if ((all_channels = malloc(sizeof(HAL_CHANNEL) * max_channels,
+ if ((all_channels = mallocarray(max_channels, sizeof(HAL_CHANNEL),
M_TEMP, M_NOWAIT | M_ZERO)) == NULL)
return (AH_FALSE);
diff --git a/sys/dev/ic/ar9003.c b/sys/dev/ic/ar9003.c
index e80726f9db8..e0ec780f740 100644
--- a/sys/dev/ic/ar9003.c
+++ b/sys/dev/ic/ar9003.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ar9003.c,v 1.28 2014/07/12 18:48:17 tedu Exp $ */
+/* $OpenBSD: ar9003.c,v 1.29 2014/07/13 23:10:23 deraadt Exp $ */
/*-
* Copyright (c) 2010 Damien Bergamini <damien.bergamini@free.fr>
@@ -725,7 +725,8 @@ ar9003_rx_alloc(struct athn_softc *sc, int qid, int count)
struct ar_rx_status *ds;
int error, i;
- rxq->bf = malloc(count * sizeof(*bf), M_DEVBUF, M_NOWAIT | M_ZERO);
+ rxq->bf = mallocarray(count, sizeof(*bf), M_DEVBUF,
+ M_NOWAIT | M_ZERO);
if (rxq->bf == NULL)
return (ENOMEM);
diff --git a/sys/dev/ic/cac.c b/sys/dev/ic/cac.c
index 2d90a355848..435dd477946 100644
--- a/sys/dev/ic/cac.c
+++ b/sys/dev/ic/cac.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cac.c,v 1.51 2014/07/12 18:48:17 tedu Exp $ */
+/* $OpenBSD: cac.c,v 1.52 2014/07/13 23:10:23 deraadt Exp $ */
/* $NetBSD: cac.c,v 1.15 2000/11/08 19:20:35 ad Exp $ */
/*
@@ -230,8 +230,8 @@ cac_init(struct cac_softc *sc, int startfw)
}
sc->sc_nunits = cinfo.num_drvs;
- sc->sc_dinfos = malloc(cinfo.num_drvs * sizeof(struct cac_drive_info),
- M_DEVBUF, M_NOWAIT | M_ZERO);
+ sc->sc_dinfos = mallocarray(cinfo.num_drvs,
+ sizeof(struct cac_drive_info), M_DEVBUF, M_NOWAIT | M_ZERO);
if (sc->sc_dinfos == NULL) {
printf("%s: cannot allocate memory for drive_info\n",
sc->sc_dv.dv_xname);
@@ -911,8 +911,8 @@ cac_create_sensors(struct cac_softc *sc)
if (ssc == NULL)
return (1);
- sc->sc_sensors = malloc(sizeof(struct ksensor) * sc->sc_nunits,
- M_DEVBUF, M_NOWAIT | M_ZERO);
+ sc->sc_sensors = mallocarray(sc->sc_nunits,
+ sizeof(struct ksensor), M_DEVBUF, M_NOWAIT | M_ZERO);
if (sc->sc_sensors == NULL)
return (1);
diff --git a/sys/dev/ic/ciss.c b/sys/dev/ic/ciss.c
index aa61a284c5c..614d4fecc42 100644
--- a/sys/dev/ic/ciss.c
+++ b/sys/dev/ic/ciss.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ciss.c,v 1.69 2014/07/12 18:48:17 tedu Exp $ */
+/* $OpenBSD: ciss.c,v 1.70 2014/07/13 23:10:23 deraadt Exp $ */
/*
* Copyright (c) 2005,2006 Michael Shalayeff
@@ -347,7 +347,7 @@ ciss_attach(struct ciss_softc *sc)
return -1;
}
- if (!(sc->sc_lds = malloc(sc->maxunits * sizeof(*sc->sc_lds),
+ if (!(sc->sc_lds = mallocarray(sc->maxunits, sizeof(*sc->sc_lds),
M_DEVBUF, M_NOWAIT | M_ZERO))) {
bus_dmamem_free(sc->dmat, sc->cmdseg, 1);
bus_dmamap_destroy(sc->dmat, sc->cmdmap);
@@ -385,7 +385,7 @@ ciss_attach(struct ciss_softc *sc)
sc->sc_flags |= CISS_BIO;
#ifndef SMALL_KERNEL
- sc->sensors = malloc(sizeof(struct ksensor) * sc->maxunits,
+ sc->sensors = mallocarray(sc->maxunits, sizeof(struct ksensor),
M_DEVBUF, M_NOWAIT | M_ZERO);
if (sc->sensors) {
struct device *dev;
diff --git a/sys/dev/ic/lance.c b/sys/dev/ic/lance.c
index 4d29cf1bd48..7f1b6492f60 100644
--- a/sys/dev/ic/lance.c
+++ b/sys/dev/ic/lance.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lance.c,v 1.2 2013/11/26 09:50:33 mpi Exp $ */
+/* $OpenBSD: lance.c,v 1.3 2014/07/13 23:10:23 deraadt Exp $ */
/* $NetBSD: lance.c,v 1.46 2012/02/02 19:43:03 tls Exp $ */
/*-
@@ -247,9 +247,9 @@ lance_config(struct lance_softc *sc)
if_attach(ifp);
ether_ifattach(ifp);
- sc->sc_rbufaddr = malloc(sc->sc_nrbuf * sizeof(int), M_DEVBUF,
+ sc->sc_rbufaddr = mallocarray(sc->sc_nrbuf, sizeof(int), M_DEVBUF,
M_WAITOK);
- sc->sc_tbufaddr = malloc(sc->sc_ntbuf * sizeof(int), M_DEVBUF,
+ sc->sc_tbufaddr = mallocarray(sc->sc_ntbuf, sizeof(int), M_DEVBUF,
M_WAITOK);
}
diff --git a/sys/dev/ic/malo.c b/sys/dev/ic/malo.c
index bf85ed4d2c6..80f442d5447 100644
--- a/sys/dev/ic/malo.c
+++ b/sys/dev/ic/malo.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: malo.c,v 1.99 2014/07/12 18:48:17 tedu Exp $ */
+/* $OpenBSD: malo.c,v 1.100 2014/07/13 23:10:23 deraadt Exp $ */
/*
* Copyright (c) 2006 Claudio Jeker <claudio@openbsd.org>
@@ -575,8 +575,8 @@ malo_alloc_rx_ring(struct malo_softc *sc, struct malo_rx_ring *ring, int count)
ring->physaddr = ring->map->dm_segs->ds_addr;
- ring->data = malloc(count * sizeof (struct malo_rx_data), M_DEVBUF,
- M_NOWAIT);
+ ring->data = mallocarray(count, sizeof (struct malo_rx_data),
+ M_DEVBUF, M_NOWAIT);
if (ring->data == NULL) {
printf("%s: could not allocate soft data\n",
sc->sc_dev.dv_xname);
@@ -734,8 +734,8 @@ malo_alloc_tx_ring(struct malo_softc *sc, struct malo_tx_ring *ring,
ring->physaddr = ring->map->dm_segs->ds_addr;
- ring->data = malloc(count * sizeof(struct malo_tx_data), M_DEVBUF,
- M_NOWAIT);
+ ring->data = mallocarray(count, sizeof(struct malo_tx_data),
+ M_DEVBUF, M_NOWAIT);
if (ring->data == NULL) {
printf("%s: could not allocate soft data\n",
sc->sc_dev.dv_xname);
diff --git a/sys/dev/ic/mfi.c b/sys/dev/ic/mfi.c
index fa15b75f4e1..5f906cb5193 100644
--- a/sys/dev/ic/mfi.c
+++ b/sys/dev/ic/mfi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mfi.c,v 1.153 2014/07/12 18:48:17 tedu Exp $ */
+/* $OpenBSD: mfi.c,v 1.154 2014/07/13 23:10:23 deraadt Exp $ */
/*
* Copyright (c) 2006 Marco Peereboom <marco@peereboom.us>
*
@@ -246,7 +246,7 @@ mfi_init_ccb(struct mfi_softc *sc)
DNPRINTF(MFI_D_CCB, "%s: mfi_init_ccb\n", DEVNAME(sc));
- sc->sc_ccb = malloc(sizeof(struct mfi_ccb) * sc->sc_max_cmds,
+ sc->sc_ccb = mallocarray(sc->sc_max_cmds, sizeof(struct mfi_ccb),
M_DEVBUF, M_WAITOK|M_ZERO);
for (i = 0; i < sc->sc_max_cmds; i++) {
@@ -2127,7 +2127,7 @@ mfi_create_sensors(struct mfi_softc *sc)
sizeof(sc->sc_sensordev.xname));
if (ISSET(letoh32(sc->sc_info.mci_adapter_ops ), MFI_INFO_AOPS_BBU)) {
- sc->sc_bbu = malloc(sizeof(*sc->sc_bbu) * 4,
+ sc->sc_bbu = mallocarray(4, sizeof(*sc->sc_bbu),
M_DEVBUF, M_WAITOK | M_ZERO);
sc->sc_bbu[0].type = SENSOR_INDICATOR;
@@ -2162,7 +2162,7 @@ mfi_create_sensors(struct mfi_softc *sc)
}
}
- sc->sc_sensors = malloc(sizeof(struct ksensor) * sc->sc_ld_cnt,
+ sc->sc_sensors = mallocarray(sc->sc_ld_cnt, sizeof(struct ksensor),
M_DEVBUF, M_NOWAIT | M_ZERO);
if (sc->sc_sensors == NULL)
return (1);
diff --git a/sys/dev/ic/mpi.c b/sys/dev/ic/mpi.c
index 86648e4ed5e..e5c77b0118f 100644
--- a/sys/dev/ic/mpi.c
+++ b/sys/dev/ic/mpi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mpi.c,v 1.192 2014/07/12 18:48:17 tedu Exp $ */
+/* $OpenBSD: mpi.c,v 1.193 2014/07/13 23:10:23 deraadt Exp $ */
/*
* Copyright (c) 2005, 2006, 2009 David Gwynne <dlg@openbsd.org>
@@ -340,8 +340,8 @@ mpi_attach(struct mpi_softc *sc)
DEVNAME(sc));
}
- sc->sc_vol_page = malloc(sc->sc_cfg_hdr.page_length * 4,
- M_TEMP, M_WAITOK | M_CANFAIL);
+ sc->sc_vol_page = mallocarray(sc->sc_cfg_hdr.page_length,
+ 4, M_TEMP, M_WAITOK | M_CANFAIL);
if (sc->sc_vol_page == NULL) {
panic("%s: can't get memory for IOC page 2, "
"bio disabled", DEVNAME(sc));
@@ -1050,7 +1050,7 @@ mpi_alloc_ccbs(struct mpi_softc *sc)
SLIST_INIT(&sc->sc_ccb_free);
mtx_init(&sc->sc_ccb_mtx, IPL_BIO);
- sc->sc_ccbs = malloc(sizeof(struct mpi_ccb) * sc->sc_maxcmds,
+ sc->sc_ccbs = mallocarray(sc->sc_maxcmds, sizeof(struct mpi_ccb),
M_DEVBUF, M_WAITOK | M_CANFAIL | M_ZERO);
if (sc->sc_ccbs == NULL) {
printf("%s: unable to allocate ccbs\n", DEVNAME(sc));
@@ -1156,7 +1156,7 @@ mpi_alloc_replies(struct mpi_softc *sc)
{
DNPRINTF(MPI_D_MISC, "%s: mpi_alloc_replies\n", DEVNAME(sc));
- sc->sc_rcbs = malloc(sc->sc_repq * sizeof(struct mpi_rcb), M_DEVBUF,
+ sc->sc_rcbs = mallocarray(sc->sc_repq, sizeof(struct mpi_rcb), M_DEVBUF,
M_WAITOK|M_CANFAIL);
if (sc->sc_rcbs == NULL)
return (1);
@@ -3430,7 +3430,7 @@ mpi_create_sensors(struct mpi_softc *sc)
if (vol == 0)
return (0);
- sc->sc_sensors = malloc(sizeof(struct ksensor) * vol,
+ sc->sc_sensors = mallocarray(vol, sizeof(struct ksensor),
M_DEVBUF, M_NOWAIT | M_ZERO);
if (sc->sc_sensors == NULL)
return (1);
diff --git a/sys/dev/ic/nvme.c b/sys/dev/ic/nvme.c
index 8e2ae166171..6b852d88e70 100644
--- a/sys/dev/ic/nvme.c
+++ b/sys/dev/ic/nvme.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nvme.c,v 1.5 2014/07/12 18:48:17 tedu Exp $ */
+/* $OpenBSD: nvme.c,v 1.6 2014/07/13 23:10:23 deraadt Exp $ */
/*
* Copyright (c) 2014 David Gwynne <dlg@openbsd.org>
@@ -511,7 +511,7 @@ nvme_ccbs_alloc(struct nvme_softc *sc, u_int nccbs)
struct nvme_ccb *ccb;
u_int i;
- sc->sc_ccbs = malloc(sizeof(*ccb) * nccbs, M_DEVBUF,
+ sc->sc_ccbs = mallocarray(nccbs, sizeof(*ccb), M_DEVBUF,
M_WAITOK | M_CANFAIL);
if (sc->sc_ccbs == NULL)
return (1);
diff --git a/sys/dev/ic/oosiop.c b/sys/dev/ic/oosiop.c
index e47023b1331..00d0a58b976 100644
--- a/sys/dev/ic/oosiop.c
+++ b/sys/dev/ic/oosiop.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: oosiop.c,v 1.21 2014/07/08 17:19:25 deraadt Exp $ */
+/* $OpenBSD: oosiop.c,v 1.22 2014/07/13 23:10:23 deraadt Exp $ */
/* $NetBSD: oosiop.c,v 1.4 2003/10/29 17:45:55 tsutsui Exp $ */
/*
@@ -292,7 +292,7 @@ oosiop_alloc_cb(struct oosiop_softc *sc, int ncb)
/*
* Allocate oosiop_cb.
*/
- cb = malloc(sizeof(*cb) * ncb, M_DEVBUF, M_NOWAIT | M_ZERO);
+ cb = mallocarray(ncb, sizeof(*cb), M_DEVBUF, M_NOWAIT | M_ZERO);
if (cb == NULL) {
printf(": failed to allocate cb memory\n");
return (ENOMEM);
diff --git a/sys/dev/ic/osiop.c b/sys/dev/ic/osiop.c
index d933010bb12..9626df5a262 100644
--- a/sys/dev/ic/osiop.c
+++ b/sys/dev/ic/osiop.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: osiop.c,v 1.48 2011/06/23 16:31:16 deraadt Exp $ */
+/* $OpenBSD: osiop.c,v 1.49 2014/07/13 23:10:23 deraadt Exp $ */
/* $NetBSD: osiop.c,v 1.9 2002/04/05 18:27:54 bouyer Exp $ */
/*
@@ -267,7 +267,7 @@ osiop_attach(sc)
/*
* Allocate (malloc) memory for acb's.
*/
- acb = malloc(sizeof(*acb) * OSIOP_NACB, M_DEVBUF, M_NOWAIT | M_ZERO);
+ acb = mallocarray(OSIOP_NACB, sizeof(*acb), M_DEVBUF, M_NOWAIT | M_ZERO);
if (acb == NULL) {
printf(": can't allocate memory for acb\n");
return;
diff --git a/sys/dev/ic/qla.c b/sys/dev/ic/qla.c
index 7a520c6ae1b..41afecbd1e6 100644
--- a/sys/dev/ic/qla.c
+++ b/sys/dev/ic/qla.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: qla.c,v 1.42 2014/07/12 18:48:17 tedu Exp $ */
+/* $OpenBSD: qla.c,v 1.43 2014/07/13 23:10:23 deraadt Exp $ */
/*
* Copyright (c) 2011 David Gwynne <dlg@openbsd.org>
@@ -2547,7 +2547,7 @@ qla_alloc_ccbs(struct qla_softc *sc)
mtx_init(&sc->sc_port_mtx, IPL_BIO);
mtx_init(&sc->sc_mbox_mtx, IPL_BIO);
- sc->sc_ccbs = malloc(sizeof(struct qla_ccb) * sc->sc_maxcmds,
+ sc->sc_ccbs = mallocarray(sc->sc_maxcmds, sizeof(struct qla_ccb),
M_DEVBUF, M_WAITOK | M_CANFAIL | M_ZERO);
if (sc->sc_ccbs == NULL) {
printf("%s: unable to allocate ccbs\n", DEVNAME(sc));
diff --git a/sys/dev/ic/qlw.c b/sys/dev/ic/qlw.c
index 37f21205760..86c32bd5125 100644
--- a/sys/dev/ic/qlw.c
+++ b/sys/dev/ic/qlw.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: qlw.c,v 1.23 2014/07/12 18:48:17 tedu Exp $ */
+/* $OpenBSD: qlw.c,v 1.24 2014/07/13 23:10:23 deraadt Exp $ */
/*
* Copyright (c) 2011 David Gwynne <dlg@openbsd.org>
@@ -1699,7 +1699,7 @@ qlw_alloc_ccbs(struct qlw_softc *sc)
mtx_init(&sc->sc_ccb_mtx, IPL_BIO);
mtx_init(&sc->sc_queue_mtx, IPL_BIO);
- sc->sc_ccbs = malloc(sizeof(struct qlw_ccb) * sc->sc_maxccbs,
+ sc->sc_ccbs = mallocarray(sc->sc_maxccbs, sizeof(struct qlw_ccb),
M_DEVBUF, M_WAITOK | M_CANFAIL | M_ZERO);
if (sc->sc_ccbs == NULL) {
printf("%s: unable to allocate ccbs\n", DEVNAME(sc));
diff --git a/sys/dev/ic/rt2560.c b/sys/dev/ic/rt2560.c
index fc9c24b0351..f460c801a65 100644
--- a/sys/dev/ic/rt2560.c
+++ b/sys/dev/ic/rt2560.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rt2560.c,v 1.64 2014/07/12 18:48:17 tedu Exp $ */
+/* $OpenBSD: rt2560.c,v 1.65 2014/07/13 23:10:23 deraadt Exp $ */
/*-
* Copyright (c) 2005, 2006
@@ -388,8 +388,8 @@ rt2560_alloc_tx_ring(struct rt2560_softc *sc, struct rt2560_tx_ring *ring,
ring->physaddr = ring->map->dm_segs->ds_addr;
- ring->data = malloc(count * sizeof (struct rt2560_tx_data), M_DEVBUF,
- M_NOWAIT | M_ZERO);
+ ring->data = mallocarray(count, sizeof (struct rt2560_tx_data),
+ M_DEVBUF, M_NOWAIT | M_ZERO);
if (ring->data == NULL) {
printf("%s: could not allocate soft data\n",
sc->sc_dev.dv_xname);
@@ -532,8 +532,8 @@ rt2560_alloc_rx_ring(struct rt2560_softc *sc, struct rt2560_rx_ring *ring,
ring->physaddr = ring->map->dm_segs->ds_addr;
- ring->data = malloc(count * sizeof (struct rt2560_rx_data), M_DEVBUF,
- M_NOWAIT | M_ZERO);
+ ring->data = mallocarray(count, sizeof (struct rt2560_rx_data),
+ M_DEVBUF, M_NOWAIT | M_ZERO);
if (ring->data == NULL) {
printf("%s: could not allocate soft data\n",
sc->sc_dev.dv_xname);
diff --git a/sys/dev/ic/rt2661.c b/sys/dev/ic/rt2661.c
index caa37d0e1ce..798ff295f28 100644
--- a/sys/dev/ic/rt2661.c
+++ b/sys/dev/ic/rt2661.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rt2661.c,v 1.73 2014/07/12 18:48:17 tedu Exp $ */
+/* $OpenBSD: rt2661.c,v 1.74 2014/07/13 23:10:23 deraadt Exp $ */
/*-
* Copyright (c) 2006
@@ -473,8 +473,8 @@ rt2661_alloc_tx_ring(struct rt2661_softc *sc, struct rt2661_tx_ring *ring,
ring->physaddr = ring->map->dm_segs->ds_addr;
- ring->data = malloc(count * sizeof (struct rt2661_tx_data), M_DEVBUF,
- M_NOWAIT | M_ZERO);
+ ring->data = mallocarray(count, sizeof (struct rt2661_tx_data),
+ M_DEVBUF, M_NOWAIT | M_ZERO);
if (ring->data == NULL) {
printf("%s: could not allocate soft data\n",
sc->sc_dev.dv_xname);
@@ -614,8 +614,8 @@ rt2661_alloc_rx_ring(struct rt2661_softc *sc, struct rt2661_rx_ring *ring,
ring->physaddr = ring->map->dm_segs->ds_addr;
- ring->data = malloc(count * sizeof (struct rt2661_rx_data), M_DEVBUF,
- M_NOWAIT | M_ZERO);
+ ring->data = mallocarray(count, sizeof (struct rt2661_rx_data),
+ M_DEVBUF, M_NOWAIT | M_ZERO);
if (ring->data == NULL) {
printf("%s: could not allocate soft data\n",
sc->sc_dev.dv_xname);
diff --git a/sys/dev/ic/rtw.c b/sys/dev/ic/rtw.c
index f63657cd3bf..7bb81932970 100644
--- a/sys/dev/ic/rtw.c
+++ b/sys/dev/ic/rtw.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtw.c,v 1.86 2014/07/12 18:48:17 tedu Exp $ */
+/* $OpenBSD: rtw.c,v 1.87 2014/07/13 23:10:23 deraadt Exp $ */
/* $NetBSD: rtw.c,v 1.29 2004/12/27 19:49:16 dyoung Exp $ */
/*-
@@ -3614,7 +3614,7 @@ rtw_txsoft_blk_setup(struct rtw_txsoft_blk *tsb, u_int qlen)
SIMPLEQ_INIT(&tsb->tsb_dirtyq);
SIMPLEQ_INIT(&tsb->tsb_freeq);
tsb->tsb_ndesc = qlen;
- tsb->tsb_desc = malloc(qlen * sizeof(*tsb->tsb_desc), M_DEVBUF,
+ tsb->tsb_desc = mallocarray(qlen, sizeof(*tsb->tsb_desc), M_DEVBUF,
M_NOWAIT);
if (tsb->tsb_desc == NULL)
return ENOMEM;
diff --git a/sys/dev/ic/sili.c b/sys/dev/ic/sili.c
index 49be864def4..4f6f0771568 100644
--- a/sys/dev/ic/sili.c
+++ b/sys/dev/ic/sili.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sili.c,v 1.52 2014/07/12 18:48:17 tedu Exp $ */
+/* $OpenBSD: sili.c,v 1.53 2014/07/13 23:10:23 deraadt Exp $ */
/*
* Copyright (c) 2007 David Gwynne <dlg@openbsd.org>
@@ -748,7 +748,7 @@ sili_ports_alloc(struct sili_softc *sc)
struct sili_port *sp;
int i;
- sc->sc_ports = malloc(sizeof(struct sili_port) * sc->sc_nports,
+ sc->sc_ports = mallocarray(sc->sc_nports, sizeof(struct sili_port),
M_DEVBUF, M_WAITOK | M_ZERO);
for (i = 0; i < sc->sc_nports; i++) {
@@ -808,7 +808,7 @@ sili_ccb_alloc(struct sili_port *sp)
TAILQ_INIT(&sp->sp_active_ccbs);
TAILQ_INIT(&sp->sp_deferred_ccbs);
- sp->sp_ccbs = malloc(sizeof(struct sili_ccb) * SILI_MAX_CMDS,
+ sp->sp_ccbs = mallocarray(SILI_MAX_CMDS, sizeof(struct sili_ccb),
M_DEVBUF, M_WAITOK);
sp->sp_cmds = sili_dmamem_alloc(sc, SILI_CMD_LEN * SILI_MAX_CMDS,
SILI_PRB_ALIGN);
diff --git a/sys/dev/ic/siop.c b/sys/dev/ic/siop.c
index d7d4a22d9b2..dcb6ab77c9e 100644
--- a/sys/dev/ic/siop.c
+++ b/sys/dev/ic/siop.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: siop.c,v 1.67 2014/07/12 18:48:17 tedu Exp $ */
+/* $OpenBSD: siop.c,v 1.68 2014/07/13 23:10:23 deraadt Exp $ */
/* $NetBSD: siop.c,v 1.79 2005/11/18 23:10:32 bouyer Exp $ */
/*
@@ -1833,7 +1833,7 @@ siop_morecbd(sc)
}
/* allocate cmd list */
- newcbd->cmds = malloc(sizeof(struct siop_cmd) * SIOP_NCMDPB,
+ newcbd->cmds = mallocarray(SIOP_NCMDPB, sizeof(struct siop_cmd),
M_DEVBUF, M_NOWAIT | M_ZERO);
if (newcbd->cmds == NULL) {
printf("%s: can't allocate memory for command descriptors\n",
diff --git a/sys/dev/ic/vga.c b/sys/dev/ic/vga.c
index 4561404e111..688fbfd2349 100644
--- a/sys/dev/ic/vga.c
+++ b/sys/dev/ic/vga.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vga.c,v 1.62 2014/07/12 18:48:17 tedu Exp $ */
+/* $OpenBSD: vga.c,v 1.63 2014/07/13 23:10:23 deraadt Exp $ */
/* $NetBSD: vga.c,v 1.28.2.1 2000/06/30 16:27:47 simonb Exp $ */
/*-
@@ -663,9 +663,8 @@ vga_alloc_screen(void *v, const struct wsscreen_descr *type, void **cookiep,
* XXX We could be more clever and use video RAM.
*/
scr = LIST_FIRST(&vc->screens);
- scr->pcs.mem =
- malloc(scr->pcs.type->ncols * scr->pcs.type->nrows * 2,
- M_DEVBUF, M_WAITOK);
+ scr->pcs.mem = mallocarray(scr->pcs.type->ncols,
+ scr->pcs.type->nrows * 2, M_DEVBUF, M_WAITOK);
}
scr = malloc(sizeof(struct vgascreen), M_DEVBUF, M_WAITOK);
@@ -676,8 +675,8 @@ vga_alloc_screen(void *v, const struct wsscreen_descr *type, void **cookiep,
vc->active = scr;
vc->currenttype = type;
} else {
- scr->pcs.mem = malloc(type->ncols * type->nrows * 2,
- M_DEVBUF, M_WAITOK);
+ scr->pcs.mem = mallocarray(type->ncols,
+ type->nrows * 2, M_DEVBUF, M_WAITOK);
pcdisplay_eraserows(&scr->pcs, 0, type->nrows, *defattrp);
}
diff --git a/sys/dev/ic/z8530tty.c b/sys/dev/ic/z8530tty.c
index c31c146b998..1d9bc0b6f25 100644
--- a/sys/dev/ic/z8530tty.c
+++ b/sys/dev/ic/z8530tty.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: z8530tty.c,v 1.24 2013/04/21 14:44:16 sebastia Exp $ */
+/* $OpenBSD: z8530tty.c,v 1.25 2014/07/13 23:10:23 deraadt Exp $ */
/* $NetBSD: z8530tty.c,v 1.77 2001/05/30 15:24:24 lukem Exp $ */
/*-
@@ -342,8 +342,8 @@ zstty_attach(struct device *parent, struct device *self, void *aux)
tp->t_hwiflow = zshwiflow;
zst->zst_tty = tp;
- zst->zst_rbuf = malloc(zstty_rbuf_size << 1, M_DEVBUF, M_WAITOK);
- zst->zst_ebuf = zst->zst_rbuf + (zstty_rbuf_size << 1);
+ zst->zst_rbuf = mallocarray(zstty_rbuf_size, 2, M_DEVBUF, M_WAITOK);
+ zst->zst_ebuf = zst->zst_rbuf + (zstty_rbuf_size * 2);
/* Disable the high water mark. */
zst->zst_r_hiwat = 0;
zst->zst_r_lowat = 0;