misc geom and gnu: 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. Differential revision: https://reviews.freebsd.org/D13837
This commit is contained in:
parent
bf156bc88c
commit
067d5edba6
@ -132,7 +132,7 @@ z_alloc(void *nil, u_int type, u_int size)
|
||||
{
|
||||
void *ptr;
|
||||
|
||||
ptr = malloc(type * size, M_GEOM_UZIP, M_NOWAIT);
|
||||
ptr = mallocarray(type, size, M_GEOM_UZIP, M_NOWAIT);
|
||||
|
||||
return (ptr);
|
||||
}
|
||||
|
@ -1620,7 +1620,7 @@ static int bwn_nphy_load_samples(struct bwn_mac *mac,
|
||||
uint16_t i;
|
||||
uint32_t *data;
|
||||
|
||||
data = malloc(len * sizeof(uint32_t), M_DEVBUF, M_NOWAIT | M_ZERO);
|
||||
data = mallocarray(len, sizeof(uint32_t), M_DEVBUF, M_NOWAIT | M_ZERO);
|
||||
if (!data) {
|
||||
BWN_ERRPRINTF(mac->mac_sc, "allocation for samples loading failed\n");
|
||||
return -ENOMEM;
|
||||
@ -1663,7 +1663,8 @@ static uint16_t bwn_nphy_gen_load_samples(struct bwn_mac *mac, uint32_t freq, ui
|
||||
len = bw << 1;
|
||||
}
|
||||
|
||||
samples = malloc(len * sizeof(struct bwn_c32), M_DEVBUF, M_NOWAIT | M_ZERO);
|
||||
samples = mallocarray(len, sizeof(struct bwn_c32), M_DEVBUF,
|
||||
M_NOWAIT | M_ZERO);
|
||||
if (!samples) {
|
||||
BWN_ERRPRINTF(mac->mac_sc, "allocation for samples generation failed\n");
|
||||
return 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user