dev/bhnd: Make use of mallocarray(9).
This makes a calloc-like definition check for overflows as is common practice.
This commit is contained in:
parent
454529cd0b
commit
92e1020a52
@ -400,7 +400,7 @@ bcma_erom_get_core_table(bhnd_erom_t *erom, struct bhnd_core_info **cores,
|
||||
}
|
||||
|
||||
/* Allocate our output buffer */
|
||||
buffer = malloc(sizeof(struct bhnd_core_info) * count, M_BHND,
|
||||
buffer = mallocarray(count, sizeof(struct bhnd_core_info), M_BHND,
|
||||
M_NOWAIT);
|
||||
if (buffer == NULL) {
|
||||
error = ENOMEM;
|
||||
|
@ -74,7 +74,7 @@ MALLOC_DECLARE(M_BHND_NVRAM);
|
||||
#define bhnd_nv_toupper(c) toupper(c)
|
||||
|
||||
#define bhnd_nv_malloc(size) malloc((size), M_BHND_NVRAM, M_NOWAIT)
|
||||
#define bhnd_nv_calloc(n, size) malloc((n) * (size), M_BHND_NVRAM, \
|
||||
#define bhnd_nv_calloc(n, size) mallocarray((n), (size), M_BHND_NVRAM, \
|
||||
M_NOWAIT | M_ZERO)
|
||||
#define bhnd_nv_reallocf(buf, size) reallocf((buf), (size), M_BHND_NVRAM, \
|
||||
M_NOWAIT)
|
||||
|
@ -445,7 +445,7 @@ siba_erom_get_core_table(bhnd_erom_t *erom, struct bhnd_core_info **cores,
|
||||
sc = (struct siba_erom *)erom;
|
||||
|
||||
/* Allocate our core array */
|
||||
out = malloc(sizeof(*out) * sc->io.ncores, M_BHND, M_NOWAIT);
|
||||
out = mallocarray(sc->io.ncores, sizeof(*out), M_BHND, M_NOWAIT);
|
||||
if (out == NULL)
|
||||
return (ENOMEM);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user