netpfil/ipfw: Make some use of mallocarray(9).
Reviewed by: kp, ae Differential Revision: https://reviews.freebsd.org/D13834
This commit is contained in:
parent
efaa3e0789
commit
454529cd0b
@ -94,7 +94,7 @@ heap_resize(struct dn_heap *h, unsigned int new_size)
|
||||
#else
|
||||
new_size = (new_size + HEAP_INCREMENT ) & ~HEAP_INCREMENT;
|
||||
#endif
|
||||
p = malloc(new_size * sizeof(*p), M_DN_HEAP, M_NOWAIT);
|
||||
p = mallocarray(new_size, sizeof(*p), M_DN_HEAP, M_NOWAIT);
|
||||
if (p == NULL) {
|
||||
printf("--- %s, resize %d failed\n", __func__, new_size );
|
||||
return 1; /* error */
|
||||
|
@ -453,8 +453,8 @@ fq_codel_new_sched(struct dn_sch_inst *_si)
|
||||
q->fs = _si->sched->fs;
|
||||
|
||||
/* allocate memory for flows array */
|
||||
si->flows = malloc(schk->cfg.flows_cnt * sizeof(struct fq_codel_flow),
|
||||
M_DUMMYNET, M_NOWAIT | M_ZERO);
|
||||
si->flows = mallocarray(schk->cfg.flows_cnt,
|
||||
sizeof(struct fq_codel_flow), M_DUMMYNET, M_NOWAIT | M_ZERO);
|
||||
if (si->flows == NULL) {
|
||||
D("cannot allocate memory for fq_codel configuration parameters");
|
||||
return ENOMEM ;
|
||||
|
@ -1034,8 +1034,8 @@ fq_pie_new_sched(struct dn_sch_inst *_si)
|
||||
return ENOMEM ;
|
||||
}
|
||||
/* allocate memory for flows array */
|
||||
si->si_extra->flows = malloc(schk->cfg.flows_cnt * sizeof(struct fq_pie_flow),
|
||||
M_DUMMYNET, M_NOWAIT | M_ZERO);
|
||||
si->si_extra->flows = mallocarray(schk->cfg.flows_cnt,
|
||||
sizeof(struct fq_pie_flow), M_DUMMYNET, M_NOWAIT | M_ZERO);
|
||||
flows = si->si_extra->flows;
|
||||
if (flows == NULL) {
|
||||
free(si->si_extra, M_DUMMYNET);
|
||||
|
Loading…
Reference in New Issue
Block a user