From 6d5bc1bcab56f14f7e3fe756325a9722b4d1c991 Mon Sep 17 00:00:00 2001 From: "Pedro F. Giffuni" Date: Mon, 15 Jan 2018 21:10:40 +0000 Subject: [PATCH] powerpc: make some use of mallocarray(9). Focus on code where we are doing multiplications within malloc(9). None of these ire likely to overflow, however the change is still useful as some static checkers can benefit from the allocation attributes we use for mallocarray. This initial sweep only covers malloc(9) calls with M_NOWAIT. No good reason but I started doing the changes before r327796 and at that time it was convenient to make sure the sorrounding code could handle NULL values. X-Differential revision: https://reviews.freebsd.org/D13837 --- sys/powerpc/pseries/phyp_vscsi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/powerpc/pseries/phyp_vscsi.c b/sys/powerpc/pseries/phyp_vscsi.c index 6c9c32f7bad..4ee715a918c 100644 --- a/sys/powerpc/pseries/phyp_vscsi.c +++ b/sys/powerpc/pseries/phyp_vscsi.c @@ -336,8 +336,8 @@ vscsi_attach(device_t dev) mtx_lock(&sc->io_lock); vscsi_setup_bus(sc); - sc->xfer = malloc(sizeof(sc->xfer[0])*sc->max_transactions, M_VSCSI, - M_NOWAIT); + sc->xfer = mallocarray(sc->max_transactions, sizeof(sc->xfer[0]), + M_VSCSI, M_NOWAIT); for (i = 0; i < sc->max_transactions; i++) { xp = &sc->xfer[i]; xp->sc = sc;