ndis: 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
This commit is contained in:
pfg 2018-01-15 21:11:38 +00:00
parent e1b1b7bd96
commit f35549b5ed

View File

@ -1351,7 +1351,7 @@ NdisMAllocateMapRegisters(ndis_handle adapter, uint32_t dmachannel,
block = (ndis_miniport_block *)adapter;
sc = device_get_softc(block->nmb_physdeviceobj->do_devext);
sc->ndis_mmaps = malloc(sizeof(bus_dmamap_t) * physmapneeded,
sc->ndis_mmaps = mallocarray(physmapneeded, sizeof(bus_dmamap_t),
M_DEVBUF, M_NOWAIT|M_ZERO);
if (sc->ndis_mmaps == NULL)