From: dhill Date: Sun, 9 Apr 2017 18:16:00 +0000 (+0000) Subject: Convert some malloc(9) to mallocarray(9) X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=91d0725a3fb5b764b9258d664ac13c73339dd442;p=openbsd Convert some malloc(9) to mallocarray(9) ok deraadt@ --- diff --git a/sys/dev/pci/azalia.c b/sys/dev/pci/azalia.c index 3d24b7b3319..bea16a3005f 100644 --- a/sys/dev/pci/azalia.c +++ b/sys/dev/pci/azalia.c @@ -1,4 +1,4 @@ -/* $OpenBSD: azalia.c,v 1.233 2017/03/19 11:18:26 jsg Exp $ */ +/* $OpenBSD: azalia.c,v 1.234 2017/04/09 18:16:00 dhill Exp $ */ /* $NetBSD: azalia.c,v 1.20 2006/05/07 08:31:44 kent Exp $ */ /*- @@ -1097,7 +1097,7 @@ azalia_init_rirb(azalia_t *az, int resuming) DPRINTF(("%s: RIRB allocation succeeded.\n", __func__)); /* setup the unsolicited response queue */ - az->unsolq = malloc(sizeof(rirb_entry_t) * UNSOLQ_SIZE, + az->unsolq = mallocarray(UNSOLQ_SIZE, sizeof(rirb_entry_t), M_DEVBUF, M_NOWAIT | M_ZERO); if (az->unsolq == NULL) { DPRINTF(("%s: can't allocate unsolicited response queue.\n", diff --git a/sys/dev/pci/if_dc_pci.c b/sys/dev/pci/if_dc_pci.c index 5856e8d577b..ea5bcefdbe6 100644 --- a/sys/dev/pci/if_dc_pci.c +++ b/sys/dev/pci/if_dc_pci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_dc_pci.c,v 1.74 2015/11/24 17:11:39 mpi Exp $ */ +/* $OpenBSD: if_dc_pci.c,v 1.75 2017/04/09 18:16:00 dhill Exp $ */ /* * Copyright (c) 1997, 1998, 1999 @@ -360,8 +360,8 @@ dc_pci_attach(struct device *parent, struct device *self, void *aux) sc->dc_type = DC_TYPE_PNIC; sc->dc_flags |= DC_TX_STORENFWD|DC_TX_INTR_ALWAYS; sc->dc_flags |= DC_PNIC_RX_BUG_WAR; - sc->dc_pnic_rx_buf = malloc(ETHER_MAX_DIX_LEN * 5, M_DEVBUF, - M_NOWAIT); + sc->dc_pnic_rx_buf = mallocarray(5, ETHER_MAX_DIX_LEN, + M_DEVBUF, M_NOWAIT); if (sc->dc_pnic_rx_buf == NULL) panic("dc_pci_attach"); if (sc->dc_revision < DC_REVISION_82C169) diff --git a/sys/dev/pci/if_nep.c b/sys/dev/pci/if_nep.c index 7518b8858dc..d824f92b335 100644 --- a/sys/dev/pci/if_nep.c +++ b/sys/dev/pci/if_nep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_nep.c,v 1.27 2017/01/22 10:17:38 dlg Exp $ */ +/* $OpenBSD: if_nep.c,v 1.28 2017/04/09 18:16:00 dhill Exp $ */ /* * Copyright (c) 2014, 2015 Mark Kettenis * @@ -1561,7 +1561,7 @@ nep_up(struct nep_softc *sc) return; sc->sc_rbdesc = NEP_DMA_KVA(sc->sc_rbring); - sc->sc_rb = malloc(sizeof(struct nep_block) * NEP_NRBDESC, + sc->sc_rb = malloc(NEP_NRBDESC, sizeof(struct nep_block), M_DEVBUF, M_WAITOK); for (i = 0; i < NEP_NRBDESC; i++) { rb = &sc->sc_rb[i]; @@ -1592,7 +1592,7 @@ nep_up(struct nep_softc *sc) goto free_rxmbox; sc->sc_txdesc = NEP_DMA_KVA(sc->sc_txring); - sc->sc_txbuf = malloc(sizeof(struct nep_buf) * NEP_NTXDESC, + sc->sc_txbuf = mallocarray(NEP_NTXDESC, sizeof(struct nep_buf), M_DEVBUF, M_WAITOK); for (i = 0; i < NEP_NTXDESC; i++) { txb = &sc->sc_txbuf[i];