summaryrefslogtreecommitdiff
path: root/sys/dev/pci
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/pci')
-rw-r--r--sys/dev/pci/agp.c4
-rw-r--r--sys/dev/pci/arc.c4
-rw-r--r--sys/dev/pci/azalia.c23
-rw-r--r--sys/dev/pci/azalia_codec.c7
-rw-r--r--sys/dev/pci/cz.c6
-rw-r--r--sys/dev/pci/emuxki.c4
-rw-r--r--sys/dev/pci/hifn7751.c6
-rw-r--r--sys/dev/pci/if_em.c10
-rw-r--r--sys/dev/pci/if_ix.c22
-rw-r--r--sys/dev/pci/if_ixgb.c10
-rw-r--r--sys/dev/pci/if_nxe.c4
-rw-r--r--sys/dev/pci/if_tht.c6
-rw-r--r--sys/dev/pci/if_txp.c7
-rw-r--r--sys/dev/pci/if_vic.c8
-rw-r--r--sys/dev/pci/ips.c6
-rw-r--r--sys/dev/pci/isp_pci.c8
-rw-r--r--sys/dev/pci/mfii.c4
-rw-r--r--sys/dev/pci/mpii.c12
-rw-r--r--sys/dev/pci/musycc.c6
-rw-r--r--sys/dev/pci/qle.c4
-rw-r--r--sys/dev/pci/safe.c4
-rw-r--r--sys/dev/pci/sdhc_pci.c6
-rw-r--r--sys/dev/pci/ubsec.c4
-rw-r--r--sys/dev/pci/virtio.c6
-rw-r--r--sys/dev/pci/vmwpvs.c5
25 files changed, 92 insertions, 94 deletions
diff --git a/sys/dev/pci/agp.c b/sys/dev/pci/agp.c
index 3b515a2ca6a..decfe9b496d 100644
--- a/sys/dev/pci/agp.c
+++ b/sys/dev/pci/agp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: agp.c,v 1.44 2014/07/12 18:48:51 tedu Exp $ */
+/* $OpenBSD: agp.c,v 1.45 2014/07/13 23:10:23 deraadt Exp $ */
/*-
* Copyright (c) 2000 Doug Rabson
* All rights reserved.
@@ -398,7 +398,7 @@ agp_generic_bind_memory(struct agp_softc *sc, struct agp_memory *mem,
*/
nseg = (mem->am_size + PAGE_SIZE - 1) / PAGE_SIZE;
- segs = malloc(nseg * sizeof *segs, M_AGP, M_WAITOK);
+ segs = mallocarray(nseg, sizeof *segs, M_AGP, M_WAITOK);
if ((error = bus_dmamem_alloc(sc->sc_dmat, mem->am_size, PAGE_SIZE, 0,
segs, nseg, &mem->am_nseg, BUS_DMA_ZERO | BUS_DMA_WAITOK)) != 0) {
free(segs, M_AGP, 0);
diff --git a/sys/dev/pci/arc.c b/sys/dev/pci/arc.c
index bc569d83b96..b3e2170064b 100644
--- a/sys/dev/pci/arc.c
+++ b/sys/dev/pci/arc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: arc.c,v 1.102 2014/07/12 18:48:51 tedu Exp $ */
+/* $OpenBSD: arc.c,v 1.103 2014/07/13 23:10:23 deraadt Exp $ */
/*
* Copyright (c) 2006 David Gwynne <dlg@openbsd.org>
@@ -2618,7 +2618,7 @@ arc_create_sensors(void *xsc, void *arg)
}
sc->sc_nsensors = bi.bi_novol;
- sc->sc_sensors = malloc(sizeof(struct ksensor) * sc->sc_nsensors,
+ sc->sc_sensors = mallocarray(sc->sc_nsensors, sizeof(struct ksensor),
M_DEVBUF, M_WAITOK | M_ZERO);
strlcpy(sc->sc_sensordev.xname, DEVNAME(sc),
diff --git a/sys/dev/pci/azalia.c b/sys/dev/pci/azalia.c
index 2882f55a622..9eaa4a16815 100644
--- a/sys/dev/pci/azalia.c
+++ b/sys/dev/pci/azalia.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: azalia.c,v 1.214 2014/07/12 18:48:51 tedu Exp $ */
+/* $OpenBSD: azalia.c,v 1.215 2014/07/13 23:10:23 deraadt Exp $ */
/* $NetBSD: azalia.c,v 1.20 2006/05/07 08:31:44 kent Exp $ */
/*-
@@ -829,7 +829,7 @@ azalia_get_ctrlr_caps(azalia_t *az)
printf("%s: no HD-Audio codecs\n", XNAME(az));
return -1;
}
- az->codecs = malloc(sizeof(codec_t) * az->ncodecs, M_DEVBUF,
+ az->codecs = mallocarray(az->ncodecs, sizeof(codec_t), M_DEVBUF,
M_NOWAIT | M_ZERO);
if (az->codecs == NULL) {
printf("%s: can't allocate memory for codecs\n", XNAME(az));
@@ -1631,7 +1631,8 @@ azalia_codec_init(codec_t *this)
return -1;
}
this->wend = this->wstart + COP_NSUBNODES(result);
- this->w = malloc(sizeof(widget_t) * this->wend, M_DEVBUF, M_NOWAIT | M_ZERO);
+ this->w = mallocarray(this->wend, sizeof(widget_t), M_DEVBUF,
+ M_NOWAIT | M_ZERO);
if (this->w == NULL) {
printf("%s: out of memory\n", XNAME(this->az));
return ENOMEM;
@@ -2054,7 +2055,7 @@ azalia_codec_sort_pins(codec_t *this)
}
}
- this->opins = malloc(nopins * sizeof(struct io_pin), M_DEVBUF,
+ this->opins = mallocarray(nopins, sizeof(struct io_pin), M_DEVBUF,
M_NOWAIT | M_ZERO);
if (this->opins == NULL)
return(ENOMEM);
@@ -2072,7 +2073,7 @@ azalia_codec_sort_pins(codec_t *this)
break;
}
- this->opins_d = malloc(nopins_d * sizeof(struct io_pin), M_DEVBUF,
+ this->opins_d = mallocarray(nopins_d, sizeof(struct io_pin), M_DEVBUF,
M_NOWAIT | M_ZERO);
if (this->opins_d == NULL)
return(ENOMEM);
@@ -2090,7 +2091,7 @@ azalia_codec_sort_pins(codec_t *this)
break;
}
- this->ipins = malloc(nipins * sizeof(struct io_pin), M_DEVBUF,
+ this->ipins = mallocarray(nipins, sizeof(struct io_pin), M_DEVBUF,
M_NOWAIT | M_ZERO);
if (this->ipins == NULL)
return(ENOMEM);
@@ -2108,7 +2109,7 @@ azalia_codec_sort_pins(codec_t *this)
break;
}
- this->ipins_d = malloc(nipins_d * sizeof(struct io_pin), M_DEVBUF,
+ this->ipins_d = mallocarray(nipins_d, sizeof(struct io_pin), M_DEVBUF,
M_NOWAIT | M_ZERO);
if (this->ipins_d == NULL)
return(ENOMEM);
@@ -2161,7 +2162,7 @@ azalia_codec_select_dacs(codec_t *this)
int nconv, conv;
int i, j, k, err;
- convs = malloc(this->na_dacs * sizeof(nid_t), M_DEVBUF,
+ convs = mallocarray(this->na_dacs, sizeof(nid_t), M_DEVBUF,
M_NOWAIT | M_ZERO);
if (convs == NULL)
return(ENOMEM);
@@ -2724,7 +2725,7 @@ azalia_codec_construct_format(codec_t *this, int newdac, int newadc)
if (this->formats != NULL)
free(this->formats, M_DEVBUF, 0);
this->nformats = 0;
- this->formats = malloc(sizeof(struct audio_format) * variation,
+ this->formats = mallocarray(variation, sizeof(struct audio_format),
M_DEVBUF, M_NOWAIT | M_ZERO);
if (this->formats == NULL) {
printf("%s: out of memory in %s\n",
@@ -3411,7 +3412,7 @@ azalia_widget_init_connection(widget_t *this, const codec_t *codec)
}
}
- this->connections = malloc(sizeof(nid_t) * nconn, M_DEVBUF, M_NOWAIT);
+ this->connections = mallocarray(nconn, sizeof(nid_t), M_DEVBUF, M_NOWAIT);
if (this->connections == NULL) {
printf("%s: out of memory\n", XNAME(codec->az));
return ENOMEM;
@@ -4427,7 +4428,7 @@ azalia_create_encodings(codec_t *this)
if (this->encs != NULL)
free(this->encs, M_DEVBUF, 0);
this->nencs = 0;
- this->encs = malloc(sizeof(struct audio_encoding) * nencs,
+ this->encs = mallocarray(nencs, sizeof(struct audio_encoding),
M_DEVBUF, M_NOWAIT | M_ZERO);
if (this->encs == NULL) {
printf("%s: out of memory in %s\n",
diff --git a/sys/dev/pci/azalia_codec.c b/sys/dev/pci/azalia_codec.c
index f12affe009d..046954a6a17 100644
--- a/sys/dev/pci/azalia_codec.c
+++ b/sys/dev/pci/azalia_codec.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: azalia_codec.c,v 1.162 2014/07/12 18:48:51 tedu Exp $ */
+/* $OpenBSD: azalia_codec.c,v 1.163 2014/07/13 23:10:23 deraadt Exp $ */
/* $NetBSD: azalia_codec.c,v 1.8 2006/05/10 11:17:27 kent Exp $ */
/*-
@@ -658,7 +658,7 @@ azalia_mixer_init(codec_t *this)
this->maxmixers = 10;
this->nmixers = 0;
- this->mixers = malloc(sizeof(mixer_item_t) * this->maxmixers,
+ this->mixers = mallocarray(this->maxmixers, sizeof(mixer_item_t),
M_DEVBUF, M_NOWAIT | M_ZERO);
if (this->mixers == NULL) {
printf("%s: out of memory in %s\n", XNAME(this), __func__);
@@ -1252,7 +1252,8 @@ azalia_mixer_ensure_capacity(codec_t *this, size_t newsize)
newmax = this->maxmixers + 10;
if (newmax < newsize)
newmax = newsize;
- newbuf = malloc(sizeof(mixer_item_t) * newmax, M_DEVBUF, M_NOWAIT | M_ZERO);
+ newbuf = mallocarray(newmax, sizeof(mixer_item_t), M_DEVBUF,
+ M_NOWAIT | M_ZERO);
if (newbuf == NULL) {
printf("%s: out of memory in %s\n", XNAME(this), __func__);
return ENOMEM;
diff --git a/sys/dev/pci/cz.c b/sys/dev/pci/cz.c
index 9f743932f0b..3703e6aabff 100644
--- a/sys/dev/pci/cz.c
+++ b/sys/dev/pci/cz.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cz.c,v 1.19 2012/03/26 16:23:22 deraadt Exp $ */
+/* $OpenBSD: cz.c,v 1.20 2014/07/13 23:10:23 deraadt Exp $ */
/* $NetBSD: cz.c,v 1.15 2001/01/20 19:10:36 thorpej Exp $ */
/*-
@@ -388,8 +388,8 @@ cz_attach(parent, self, aux)
return;
}
- cz->cz_ports = malloc(sizeof(struct cztty_softc) * cz->cz_nchannels,
- M_DEVBUF, M_WAITOK | M_ZERO);
+ cz->cz_ports = mallocarray(cz->cz_nchannels,
+ sizeof(struct cztty_softc), M_DEVBUF, M_WAITOK | M_ZERO);
cztty_attached_ttys += cz->cz_nchannels;
for (i = 0; i < cz->cz_nchannels; i++) {
diff --git a/sys/dev/pci/emuxki.c b/sys/dev/pci/emuxki.c
index eca0c3cbfd4..740c0e74879 100644
--- a/sys/dev/pci/emuxki.c
+++ b/sys/dev/pci/emuxki.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: emuxki.c,v 1.45 2014/07/12 18:48:51 tedu Exp $ */
+/* $OpenBSD: emuxki.c,v 1.46 2014/07/13 23:10:23 deraadt Exp $ */
/* $NetBSD: emuxki.c,v 1.1 2001/10/17 18:39:41 jdolecek Exp $ */
/*-
@@ -293,7 +293,7 @@ emuxki_dmamem_alloc(bus_dma_tag_t dmat, size_t size, bus_size_t align,
mem->nsegs = nsegs;
mem->bound = 0;
- mem->segs = malloc(mem->nsegs * sizeof(*(mem->segs)), type, flags);
+ mem->segs = mallocarray(mem->nsegs, sizeof(*(mem->segs)), type, flags);
if (mem->segs == NULL) {
free(mem, type, 0);
return (NULL);
diff --git a/sys/dev/pci/hifn7751.c b/sys/dev/pci/hifn7751.c
index 766c7117037..d3ff0c5529d 100644
--- a/sys/dev/pci/hifn7751.c
+++ b/sys/dev/pci/hifn7751.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hifn7751.c,v 1.168 2014/07/12 18:48:51 tedu Exp $ */
+/* $OpenBSD: hifn7751.c,v 1.169 2014/07/13 23:10:23 deraadt Exp $ */
/*
* Invertex AEON / Hifn 7751 driver
@@ -1847,8 +1847,8 @@ hifn_newsession(u_int32_t *sidp, struct cryptoini *cri)
if (ses == NULL) {
sesn = sc->sc_nsessions;
- ses = (struct hifn_session *)malloc((sesn + 1) *
- sizeof(*ses), M_DEVBUF, M_NOWAIT);
+ ses = mallocarray((sesn + 1), sizeof(*ses),
+ M_DEVBUF, M_NOWAIT);
if (ses == NULL)
return (ENOMEM);
bcopy(sc->sc_sessions, ses, sesn * sizeof(*ses));
diff --git a/sys/dev/pci/if_em.c b/sys/dev/pci/if_em.c
index 344087749bb..d6d7e8eaecc 100644
--- a/sys/dev/pci/if_em.c
+++ b/sys/dev/pci/if_em.c
@@ -31,7 +31,7 @@ POSSIBILITY OF SUCH DAMAGE.
***************************************************************************/
-/* $OpenBSD: if_em.c,v 1.286 2014/07/12 18:48:51 tedu Exp $ */
+/* $OpenBSD: if_em.c,v 1.287 2014/07/13 23:10:23 deraadt Exp $ */
/* $FreeBSD: if_em.c,v 1.46 2004/09/29 18:28:28 mlaier Exp $ */
#include <dev/pci/if_em.h>
@@ -2119,8 +2119,8 @@ em_dma_free(struct em_softc *sc, struct em_dma_alloc *dma)
int
em_allocate_transmit_structures(struct em_softc *sc)
{
- if (!(sc->tx_buffer_area = malloc(sizeof(struct em_buffer) *
- sc->num_tx_desc, M_DEVBUF, M_NOWAIT | M_ZERO))) {
+ if (!(sc->tx_buffer_area = mallocarray(sc->num_tx_desc,
+ sizeof(struct em_buffer), M_DEVBUF, M_NOWAIT | M_ZERO))) {
printf("%s: Unable to allocate tx_buffer memory\n",
sc->sc_dv.dv_xname);
return (ENOMEM);
@@ -2553,8 +2553,8 @@ em_allocate_receive_structures(struct em_softc *sc)
int i, error;
struct em_buffer *rx_buffer;
- if (!(sc->rx_buffer_area = malloc(sizeof(struct em_buffer) *
- sc->num_rx_desc, M_DEVBUF, M_NOWAIT | M_ZERO))) {
+ if (!(sc->rx_buffer_area = mallocarray(sc->num_rx_desc,
+ sizeof(struct em_buffer), M_DEVBUF, M_NOWAIT | M_ZERO))) {
printf("%s: Unable to allocate rx_buffer memory\n",
sc->sc_dv.dv_xname);
return (ENOMEM);
diff --git a/sys/dev/pci/if_ix.c b/sys/dev/pci/if_ix.c
index 500c15578cb..8467ed40c48 100644
--- a/sys/dev/pci/if_ix.c
+++ b/sys/dev/pci/if_ix.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_ix.c,v 1.95 2014/07/12 18:48:51 tedu Exp $ */
+/* $OpenBSD: if_ix.c,v 1.96 2014/07/13 23:10:23 deraadt Exp $ */
/******************************************************************************
@@ -1703,25 +1703,22 @@ ixgbe_allocate_queues(struct ix_softc *sc)
int txconf = 0, rxconf = 0, i;
/* First allocate the top level queue structs */
- if (!(sc->queues =
- (struct ix_queue *) malloc(sizeof(struct ix_queue) *
- sc->num_queues, M_DEVBUF, M_NOWAIT | M_ZERO))) {
+ if (!(sc->queues = mallocarray(sc->num_queues,
+ sizeof(struct ix_queue), M_DEVBUF, M_NOWAIT | M_ZERO))) {
printf("%s: Unable to allocate queue memory\n", ifp->if_xname);
goto fail;
}
/* Then allocate the TX ring struct memory */
- if (!(sc->tx_rings =
- (struct tx_ring *) malloc(sizeof(struct tx_ring) *
- sc->num_queues, M_DEVBUF, M_NOWAIT | M_ZERO))) {
+ if (!(sc->tx_rings = mallocarray(sc->num_queues,
+ sizeof(struct tx_ring), M_DEVBUF, M_NOWAIT | M_ZERO))) {
printf("%s: Unable to allocate TX ring memory\n", ifp->if_xname);
goto fail;
}
/* Next allocate the RX */
- if (!(sc->rx_rings =
- (struct rx_ring *) malloc(sizeof(struct rx_ring) *
- sc->num_queues, M_DEVBUF, M_NOWAIT | M_ZERO))) {
+ if (!(sc->rx_rings = mallocarray(sc->num_queues,
+ sizeof(struct rx_ring), M_DEVBUF, M_NOWAIT | M_ZERO))) {
printf("%s: Unable to allocate RX ring memory\n", ifp->if_xname);
goto rx_fail;
}
@@ -1814,9 +1811,8 @@ ixgbe_allocate_transmit_buffers(struct tx_ring *txr)
struct ixgbe_tx_buf *txbuf;
int error, i;
- if (!(txr->tx_buffers =
- (struct ixgbe_tx_buf *) malloc(sizeof(struct ixgbe_tx_buf) *
- sc->num_tx_desc, M_DEVBUF, M_NOWAIT | M_ZERO))) {
+ if (!(txr->tx_buffers = mallocarray(sc->num_tx_desc,
+ sizeof(struct ixgbe_tx_buf), M_DEVBUF, M_NOWAIT | M_ZERO))) {
printf("%s: Unable to allocate tx_buffer memory\n",
ifp->if_xname);
error = ENOMEM;
diff --git a/sys/dev/pci/if_ixgb.c b/sys/dev/pci/if_ixgb.c
index 01177056862..cac1a736a66 100644
--- a/sys/dev/pci/if_ixgb.c
+++ b/sys/dev/pci/if_ixgb.c
@@ -31,7 +31,7 @@ POSSIBILITY OF SUCH DAMAGE.
***************************************************************************/
-/* $OpenBSD: if_ixgb.c,v 1.61 2014/07/12 18:48:51 tedu Exp $ */
+/* $OpenBSD: if_ixgb.c,v 1.62 2014/07/13 23:10:23 deraadt Exp $ */
#include <dev/pci/if_ixgb.h>
@@ -1135,8 +1135,8 @@ ixgb_dma_free(struct ixgb_softc *sc, struct ixgb_dma_alloc *dma)
int
ixgb_allocate_transmit_structures(struct ixgb_softc *sc)
{
- if (!(sc->tx_buffer_area = malloc(sizeof(struct ixgb_buffer) *
- sc->num_tx_desc, M_DEVBUF, M_NOWAIT | M_ZERO))) {
+ if (!(sc->tx_buffer_area = mallocarray(sc->num_tx_desc,
+ sizeof(struct ixgb_buffer), M_DEVBUF, M_NOWAIT | M_ZERO))) {
printf("%s: Unable to allocate tx_buffer memory\n",
sc->sc_dv.dv_xname);
return (ENOMEM);
@@ -1501,8 +1501,8 @@ ixgb_allocate_receive_structures(struct ixgb_softc *sc)
int i, error;
struct ixgb_buffer *rx_buffer;
- if (!(sc->rx_buffer_area = malloc(sizeof(struct ixgb_buffer) *
- sc->num_rx_desc, M_DEVBUF, M_NOWAIT | M_ZERO))) {
+ if (!(sc->rx_buffer_area = mallocarray(sc->num_rx_desc,
+ sizeof(struct ixgb_buffer), M_DEVBUF, M_NOWAIT | M_ZERO))) {
printf("%s: Unable to allocate rx_buffer memory\n",
sc->sc_dv.dv_xname);
return (ENOMEM);
diff --git a/sys/dev/pci/if_nxe.c b/sys/dev/pci/if_nxe.c
index 6258787258f..3f3e972626e 100644
--- a/sys/dev/pci/if_nxe.c
+++ b/sys/dev/pci/if_nxe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_nxe.c,v 1.65 2014/07/12 18:48:51 tedu Exp $ */
+/* $OpenBSD: if_nxe.c,v 1.66 2014/07/13 23:10:23 deraadt Exp $ */
/*
* Copyright (c) 2007 David Gwynne <dlg@openbsd.org>
@@ -1926,7 +1926,7 @@ nxe_pkt_alloc(struct nxe_softc *sc, u_int npkts, int nsegs)
int i;
npl = malloc(sizeof(*npl), M_DEVBUF, M_WAITOK | M_ZERO);
- pkt = malloc(sizeof(*pkt) * npkts, M_DEVBUF, M_WAITOK | M_ZERO);
+ pkt = mallocarray(npkts, sizeof(*pkt), M_DEVBUF, M_WAITOK | M_ZERO);
npl->npl_pkts = pkt;
TAILQ_INIT(&npl->npl_free);
diff --git a/sys/dev/pci/if_tht.c b/sys/dev/pci/if_tht.c
index e8928f84196..75a6824788f 100644
--- a/sys/dev/pci/if_tht.c
+++ b/sys/dev/pci/if_tht.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_tht.c,v 1.127 2014/07/12 18:48:52 tedu Exp $ */
+/* $OpenBSD: if_tht.c,v 1.128 2014/07/13 23:10:23 deraadt Exp $ */
/*
* Copyright (c) 2007 David Gwynne <dlg@openbsd.org>
@@ -1879,8 +1879,8 @@ tht_pkt_alloc(struct tht_softc *sc, struct tht_pkt_list *tpl, int npkts,
struct tht_pkt *pkt;
int i;
- tpl->tpl_pkts = malloc(sizeof(struct tht_pkt) * npkts, M_DEVBUF,
- M_WAITOK | M_ZERO);
+ tpl->tpl_pkts = mallocarray(npkts, sizeof(struct tht_pkt),
+ M_DEVBUF, M_WAITOK | M_ZERO);
TAILQ_INIT(&tpl->tpl_free);
TAILQ_INIT(&tpl->tpl_used);
diff --git a/sys/dev/pci/if_txp.c b/sys/dev/pci/if_txp.c
index 726fe0dcc12..3fc6240caf5 100644
--- a/sys/dev/pci/if_txp.c
+++ b/sys/dev/pci/if_txp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_txp.c,v 1.109 2014/07/12 18:48:52 tedu Exp $ */
+/* $OpenBSD: if_txp.c,v 1.110 2014/07/13 23:10:23 deraadt Exp $ */
/*
* Copyright (c) 2001
@@ -1585,9 +1585,8 @@ txp_response(struct txp_softc *sc, u_int32_t ridx, u_int16_t id,
rsp = (struct txp_rsp_desc *)(((u_int8_t *)sc->sc_rspring.base) + ridx);
if (id == letoh16(rsp->rsp_id) && letoh16(rsp->rsp_seq) == seq) {
- *rspp = (struct txp_rsp_desc *)malloc(
- sizeof(struct txp_rsp_desc) * (rsp->rsp_numdesc + 1),
- M_DEVBUF, M_NOWAIT);
+ *rspp = mallocarray(rsp->rsp_numdesc + 1,
+ sizeof(struct txp_rsp_desc), M_DEVBUF, M_NOWAIT);
if ((*rspp) == NULL)
return (-1);
txp_rsp_fixup(sc, rsp, *rspp);
diff --git a/sys/dev/pci/if_vic.c b/sys/dev/pci/if_vic.c
index 747be9a9efe..3fc1646415b 100644
--- a/sys/dev/pci/if_vic.c
+++ b/sys/dev/pci/if_vic.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_vic.c,v 1.80 2014/07/12 18:48:52 tedu Exp $ */
+/* $OpenBSD: if_vic.c,v 1.81 2014/07/13 23:10:23 deraadt Exp $ */
/*
* Copyright (c) 2006 Reyk Floeter <reyk@openbsd.org>
@@ -567,15 +567,15 @@ vic_alloc_data(struct vic_softc *sc)
sc->sc_rxq[1].pktlen = 4096;
for (q = 0; q < VIC_NRXRINGS; q++) {
- sc->sc_rxq[q].bufs = malloc(sizeof(struct vic_rxbuf) *
- sc->sc_nrxbuf, M_DEVBUF, M_NOWAIT | M_ZERO);
+ sc->sc_rxq[q].bufs = mallocarray(sc->sc_nrxbuf,
+ sizeof(struct vic_rxbuf), M_DEVBUF, M_NOWAIT | M_ZERO);
if (sc->sc_rxq[q].bufs == NULL) {
printf(": unable to allocate rxbuf for ring %d\n", q);
goto freerx;
}
}
- sc->sc_txbuf = malloc(sizeof(struct vic_txbuf) * sc->sc_ntxbuf,
+ sc->sc_txbuf = mallocarray(sc->sc_ntxbuf, sizeof(struct vic_txbuf),
M_DEVBUF, M_NOWAIT);
if (sc->sc_txbuf == NULL) {
printf(": unable to allocate txbuf\n");
diff --git a/sys/dev/pci/ips.c b/sys/dev/pci/ips.c
index 9a2b5fc75cc..83c62d8a346 100644
--- a/sys/dev/pci/ips.c
+++ b/sys/dev/pci/ips.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ips.c,v 1.109 2014/07/12 18:48:52 tedu Exp $ */
+/* $OpenBSD: ips.c,v 1.110 2014/07/13 23:10:23 deraadt Exp $ */
/*
* Copyright (c) 2006, 2007, 2009 Alexander Yurchenko <grange@openbsd.org>
@@ -796,7 +796,7 @@ ips_attach(struct device *parent, struct device *self, void *aux)
#ifndef SMALL_KERNEL
/* Add sensors */
- if ((sc->sc_sensors = malloc(sizeof(struct ksensor) * sc->sc_nunits,
+ if ((sc->sc_sensors = mallocarray(sc->sc_nunits, sizeof(struct ksensor),
M_DEVBUF, M_NOWAIT | M_ZERO)) == NULL) {
printf(": can't alloc sensors\n");
return;
@@ -1981,7 +1981,7 @@ ips_ccb_alloc(struct ips_softc *sc, int n)
struct ips_ccb *ccb;
int i;
- if ((ccb = malloc(n * sizeof(*ccb), M_DEVBUF,
+ if ((ccb = mallocarray(n, sizeof(*ccb), M_DEVBUF,
M_NOWAIT | M_ZERO)) == NULL)
return (NULL);
diff --git a/sys/dev/pci/isp_pci.c b/sys/dev/pci/isp_pci.c
index 16e057ba912..5ec22bbb6fd 100644
--- a/sys/dev/pci/isp_pci.c
+++ b/sys/dev/pci/isp_pci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: isp_pci.c,v 1.60 2014/07/12 18:48:52 tedu Exp $ */
+/* $OpenBSD: isp_pci.c,v 1.61 2014/07/13 23:10:23 deraadt Exp $ */
/* $FreeBSD: src/sys/dev/isp/isp_pci.c,v 1.148 2007/06/26 23:08:57 mjacob Exp $*/
/*-
* Copyright (c) 1997-2006 by Matthew Jacob
@@ -560,7 +560,7 @@ isp_pci_attach(struct device *parent, struct device *self, void *aux)
if (pa->pa_id == PCI_QLOGIC_ISP1240) {
isp->isp_mdvec = &mdvec_1080;
isp->isp_type = ISP_HA_SCSI_1240;
- isp->isp_param = malloc(2 * sizeof(sdparam), M_DEVBUF,
+ isp->isp_param = mallocarray(2, sizeof(sdparam), M_DEVBUF,
M_NOWAIT | M_ZERO);
if (isp->isp_param == NULL) {
printf(nomem);
@@ -572,7 +572,7 @@ isp_pci_attach(struct device *parent, struct device *self, void *aux)
if (pa->pa_id == PCI_QLOGIC_ISP1280) {
isp->isp_mdvec = &mdvec_1080;
isp->isp_type = ISP_HA_SCSI_1280;
- isp->isp_param = malloc(2 * sizeof(sdparam),
+ isp->isp_param = mallocarray(2, sizeof(sdparam),
M_DEVBUF, M_NOWAIT | M_ZERO);
if (isp->isp_param == NULL) {
printf(nomem);
@@ -596,7 +596,7 @@ isp_pci_attach(struct device *parent, struct device *self, void *aux)
if (pa->pa_id == PCI_QLOGIC_ISP12160) {
isp->isp_mdvec = &mdvec_12160;
isp->isp_type = ISP_HA_SCSI_12160;
- isp->isp_param = malloc(2 * sizeof(sdparam),
+ isp->isp_param = mallocarray(2, sizeof(sdparam),
M_DEVBUF, M_NOWAIT | M_ZERO);
if (isp->isp_param == NULL) {
printf(nomem);
diff --git a/sys/dev/pci/mfii.c b/sys/dev/pci/mfii.c
index 72e736afaed..604c123eb93 100644
--- a/sys/dev/pci/mfii.c
+++ b/sys/dev/pci/mfii.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mfii.c,v 1.16 2014/07/12 18:48:52 tedu Exp $ */
+/* $OpenBSD: mfii.c,v 1.17 2014/07/13 23:10:23 deraadt Exp $ */
/*
* Copyright (c) 2012 David Gwynne <dlg@openbsd.org>
@@ -1382,7 +1382,7 @@ mfii_init_ccb(struct mfii_softc *sc)
u_int i;
int error;
- sc->sc_ccb = malloc(sizeof(struct mfii_ccb) * sc->sc_max_cmds,
+ sc->sc_ccb = mallocarray(sc->sc_max_cmds, sizeof(struct mfii_ccb),
M_DEVBUF, M_WAITOK|M_ZERO);
for (i = 0; i < sc->sc_max_cmds; i++) {
diff --git a/sys/dev/pci/mpii.c b/sys/dev/pci/mpii.c
index d521b461d87..f160c96b81e 100644
--- a/sys/dev/pci/mpii.c
+++ b/sys/dev/pci/mpii.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mpii.c,v 1.95 2014/07/12 18:48:52 tedu Exp $ */
+/* $OpenBSD: mpii.c,v 1.96 2014/07/13 23:10:23 deraadt Exp $ */
/*
* Copyright (c) 2010, 2012 Mike Belopuhov
* Copyright (c) 2009 James Giannoules
@@ -553,7 +553,7 @@ mpii_attach(struct device *parent, struct device *self, void *aux)
}
}
- sc->sc_devs = malloc(sc->sc_max_devices *
+ sc->sc_devs = mallocarray(sc->sc_max_devices,
sizeof(struct mpii_device *), M_DEVBUF, M_NOWAIT | M_ZERO);
if (sc->sc_devs == NULL) {
printf("%s: unable to allocate memory for mpii_device\n",
@@ -2366,7 +2366,7 @@ mpii_alloc_ccbs(struct mpii_softc *sc)
scsi_ioh_set(&sc->sc_ccb_tmo_handler, &sc->sc_iopool,
mpii_scsi_cmd_tmo_handler, sc);
- sc->sc_ccbs = malloc(sizeof(*ccb) * (sc->sc_max_cmds-1),
+ sc->sc_ccbs = mallocarray((sc->sc_max_cmds-1), sizeof(*ccb),
M_DEVBUF, M_NOWAIT | M_ZERO);
if (sc->sc_ccbs == NULL) {
printf("%s: unable to allocate ccbs\n", DEVNAME(sc));
@@ -2471,8 +2471,8 @@ mpii_alloc_replies(struct mpii_softc *sc)
{
DNPRINTF(MPII_D_MISC, "%s: mpii_alloc_replies\n", DEVNAME(sc));
- sc->sc_rcbs = malloc(sc->sc_num_reply_frames * sizeof(struct mpii_rcb),
- M_DEVBUF, M_NOWAIT);
+ sc->sc_rcbs = mallocarray(sc->sc_num_reply_frames,
+ sizeof(struct mpii_rcb), M_DEVBUF, M_NOWAIT);
if (sc->sc_rcbs == NULL)
return (1);
@@ -3530,7 +3530,7 @@ mpii_create_sensors(struct mpii_softc *sc)
struct scsi_link *link;
int i;
- sc->sc_sensors = malloc(sizeof(struct ksensor) * sc->sc_vd_count,
+ sc->sc_sensors = mallocarray(sc->sc_vd_count, sizeof(struct ksensor),
M_DEVBUF, M_NOWAIT | M_ZERO);
if (sc->sc_sensors == NULL)
return (1);
diff --git a/sys/dev/pci/musycc.c b/sys/dev/pci/musycc.c
index 6a57d691c9f..ae73a363f0b 100644
--- a/sys/dev/pci/musycc.c
+++ b/sys/dev/pci/musycc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: musycc.c,v 1.21 2010/05/19 15:27:35 oga Exp $ */
+/* $OpenBSD: musycc.c,v 1.22 2014/07/13 23:10:23 deraadt Exp $ */
/*
* Copyright (c) 2004,2005 Internet Business Solutions AG, Zurich, Switzerland
@@ -115,8 +115,8 @@ musycc_attach_common(struct musycc_softc *sc, u_int32_t portmap, u_int32_t mode)
MUSYCC_CONF_BLAPSE_SET(3) | MUSYCC_CONF_INTB;
/* initialize group descriptors */
- sc->mc_groups = malloc(sc->mc_ngroups * sizeof(struct musycc_group),
- M_DEVBUF, M_NOWAIT | M_ZERO);
+ sc->mc_groups = mallocarray(sc->mc_ngroups,
+ sizeof(struct musycc_group), M_DEVBUF, M_NOWAIT | M_ZERO);
if (sc->mc_groups == NULL) {
printf(": couldn't alloc group descriptors\n");
musycc_free_groupdesc(sc);
diff --git a/sys/dev/pci/qle.c b/sys/dev/pci/qle.c
index 91a1f6691d1..e15e49b92e6 100644
--- a/sys/dev/pci/qle.c
+++ b/sys/dev/pci/qle.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: qle.c,v 1.30 2014/07/12 18:48:52 tedu Exp $ */
+/* $OpenBSD: qle.c,v 1.31 2014/07/13 23:10:23 deraadt Exp $ */
/*
* Copyright (c) 2013, 2014 Jonathan Matthew <jmatthew@openbsd.org>
@@ -2844,7 +2844,7 @@ qle_alloc_ccbs(struct qle_softc *sc)
mtx_init(&sc->sc_port_mtx, IPL_BIO);
mtx_init(&sc->sc_mbox_mtx, IPL_BIO);
- sc->sc_ccbs = malloc(sizeof(struct qle_ccb) * sc->sc_maxcmds,
+ sc->sc_ccbs = mallocarray(sc->sc_maxcmds, sizeof(struct qle_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/pci/safe.c b/sys/dev/pci/safe.c
index 25359933fd0..afcd42beacf 100644
--- a/sys/dev/pci/safe.c
+++ b/sys/dev/pci/safe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: safe.c,v 1.36 2014/07/12 18:48:52 tedu Exp $ */
+/* $OpenBSD: safe.c,v 1.37 2014/07/13 23:10:23 deraadt Exp $ */
/*-
* Copyright (c) 2003 Sam Leffler, Errno Consulting
@@ -1344,7 +1344,7 @@ safe_newsession(u_int32_t *sidp, struct cryptoini *cri)
if (ses == NULL) {
sesn = sc->sc_nsessions;
- ses = (struct safe_session *)malloc((sesn + 1) *
+ ses = mallocarray((sesn + 1),
sizeof(struct safe_session), M_DEVBUF, M_NOWAIT);
if (ses == NULL)
return (ENOMEM);
diff --git a/sys/dev/pci/sdhc_pci.c b/sys/dev/pci/sdhc_pci.c
index 77dc54d1627..b2fe50b4b96 100644
--- a/sys/dev/pci/sdhc_pci.c
+++ b/sys/dev/pci/sdhc_pci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sdhc_pci.c,v 1.14 2013/01/04 23:19:40 stsp Exp $ */
+/* $OpenBSD: sdhc_pci.c,v 1.15 2014/07/13 23:10:23 deraadt Exp $ */
/*
* Copyright (c) 2006 Uwe Stuehler <uwe@openbsd.org>
@@ -158,8 +158,8 @@ sdhc_pci_attach(struct device *parent, struct device *self, void *aux)
nslots = SDHC_PCI_NUM_SLOTS(slotinfo);
/* Allocate an array big enough to hold all the possible hosts */
- sc->sc.sc_host = malloc(sizeof(struct sdhc_host *) * nslots, M_DEVBUF,
- M_WAITOK);
+ sc->sc.sc_host = mallocarray(nslots, sizeof(struct sdhc_host *),
+ M_DEVBUF, M_WAITOK);
/* XXX: handle 64-bit BARs */
for (reg = SDHC_PCI_BAR_START + SDHC_PCI_FIRST_BAR(slotinfo) *
diff --git a/sys/dev/pci/ubsec.c b/sys/dev/pci/ubsec.c
index 20f36157f2b..da16458bac9 100644
--- a/sys/dev/pci/ubsec.c
+++ b/sys/dev/pci/ubsec.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ubsec.c,v 1.158 2014/07/12 18:48:52 tedu Exp $ */
+/* $OpenBSD: ubsec.c,v 1.159 2014/07/13 23:10:23 deraadt Exp $ */
/*
* Copyright (c) 2000 Jason L. Wright (jason@thought.net)
@@ -693,7 +693,7 @@ ubsec_newsession(u_int32_t *sidp, struct cryptoini *cri)
if (ses == NULL) {
sesn = sc->sc_nsessions;
- ses = (struct ubsec_session *)malloc((sesn + 1) *
+ ses = mallocarray((sesn + 1),
sizeof(struct ubsec_session), M_DEVBUF, M_NOWAIT);
if (ses == NULL)
return (ENOMEM);
diff --git a/sys/dev/pci/virtio.c b/sys/dev/pci/virtio.c
index d353b15d401..553a6a7ee66 100644
--- a/sys/dev/pci/virtio.c
+++ b/sys/dev/pci/virtio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: virtio.c,v 1.8 2014/07/12 18:48:52 tedu Exp $ */
+/* $OpenBSD: virtio.c,v 1.9 2014/07/13 23:10:23 deraadt Exp $ */
/* $NetBSD: virtio.c,v 1.3 2011/11/02 23:05:52 njoly Exp $ */
/*
@@ -379,8 +379,8 @@ virtio_alloc_vq(struct virtio_softc *sc,
vq->vq_maxnsegs = maxnsegs;
/* free slot management */
- vq->vq_entries = malloc(sizeof(struct vq_entry)*vq_size,
- M_DEVBUF, M_NOWAIT | M_ZERO);
+ vq->vq_entries = mallocarray(vq_size, sizeof(struct vq_entry),
+ M_DEVBUF, M_NOWAIT | M_ZERO);
if (vq->vq_entries == NULL) {
r = ENOMEM;
goto err;
diff --git a/sys/dev/pci/vmwpvs.c b/sys/dev/pci/vmwpvs.c
index a1a90a17eef..e368d743ffd 100644
--- a/sys/dev/pci/vmwpvs.c
+++ b/sys/dev/pci/vmwpvs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vmwpvs.c,v 1.9 2014/07/12 18:48:52 tedu Exp $ */
+/* $OpenBSD: vmwpvs.c,v 1.10 2014/07/13 23:10:23 deraadt Exp $ */
/*
* Copyright (c) 2013 David Gwynne <dlg@openbsd.org>
@@ -507,7 +507,8 @@ vmwpvs_attach(struct device *parent, struct device *self, void *aux)
goto free_sgl;
}
- sc->sc_ccbs = malloc(sizeof(struct vmwpvs_ccb) * r, M_DEVBUF, M_WAITOK);
+ sc->sc_ccbs = mallocarray(r, sizeof(struct vmwpvs_ccb),
+ M_DEVBUF, M_WAITOK);
/* cant fail */
sgls = VMWPVS_DMA_KVA(sc->sc_sgls);