From: dhill Date: Sun, 9 Apr 2017 18:07:19 +0000 (+0000) Subject: Convert some malloc(9) to mallocarray(9) X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=1b67e2c532f582b600c7da95be7675e6b92fd9fb;p=openbsd Convert some malloc(9) to mallocarray(9) ok deraadt@ --- diff --git a/sys/dev/ic/aac.c b/sys/dev/ic/aac.c index 84f6d7a2670..b6188b64e65 100644 --- a/sys/dev/ic/aac.c +++ b/sys/dev/ic/aac.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aac.c,v 1.68 2017/04/08 02:57:24 deraadt Exp $ */ +/* $OpenBSD: aac.c,v 1.69 2017/04/09 18:07:19 dhill Exp $ */ /*- * Copyright (c) 2000 Michael Smith @@ -1277,7 +1277,7 @@ aac_init(struct aac_softc *sc) /* Allocate some FIBs and associated command structs */ TAILQ_INIT(&sc->aac_fibmap_tqh); - sc->aac_commands = malloc(AAC_MAX_FIBS * sizeof(struct aac_command), + sc->aac_commands = mallocarray(AAC_MAX_FIBS, sizeof(struct aac_command), M_DEVBUF, M_WAITOK | M_ZERO); while (sc->total_fibs < AAC_MAX_FIBS) { if (aac_alloc_commands(sc) != 0) diff --git a/sys/dev/ic/adw.c b/sys/dev/ic/adw.c index 491a1bd9159..baebe59b76a 100644 --- a/sys/dev/ic/adw.c +++ b/sys/dev/ic/adw.c @@ -1,4 +1,4 @@ -/* $OpenBSD: adw.c,v 1.52 2015/03/14 03:38:47 jsg Exp $ */ +/* $OpenBSD: adw.c,v 1.53 2017/04/09 18:07:19 dhill Exp $ */ /* $NetBSD: adw.c,v 1.23 2000/05/27 18:24:50 dante Exp $ */ /* @@ -144,7 +144,7 @@ adw_alloc_carriers(ADW_SOFTC *sc) * Allocate the control structure. */ sc->sc_control->carriers = - malloc(sizeof(ADW_CARRIER) * ADW_MAX_CARRIER, M_DEVBUF, + mallocarray(ADW_MAX_CARRIER, sizeof(ADW_CARRIER), M_DEVBUF, M_NOWAIT); if (sc->sc_control->carriers == NULL) return (ENOMEM); diff --git a/sys/dev/ic/ath.c b/sys/dev/ic/ath.c index 704eb5d50a3..3a0520da9f4 100644 --- a/sys/dev/ic/ath.c +++ b/sys/dev/ic/ath.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ath.c,v 1.112 2017/01/22 10:17:37 dlg Exp $ */ +/* $OpenBSD: ath.c,v 1.113 2017/04/09 18:07:19 dhill Exp $ */ /* $NetBSD: ath.c,v 1.37 2004/08/18 21:59:39 dyoung Exp $ */ /*- @@ -2973,7 +2973,7 @@ ath_getchannels(struct ath_softc *sc, HAL_BOOL outdoor, HAL_BOOL xchanmode) int i, ix, nchan; sc->sc_nchan = 0; - chans = malloc(IEEE80211_CHAN_MAX * sizeof(HAL_CHANNEL), + chans = mallocarray(IEEE80211_CHAN_MAX, sizeof(HAL_CHANNEL), M_TEMP, M_NOWAIT); if (chans == NULL) { printf("%s: unable to allocate channel table\n", ifp->if_xname);