Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net/fq_impl: Switch to kvmalloc() for memory allocation

The FQ implementation used by mac80211 allocates memory using kmalloc(),
which can fail; and Johannes reported that this actually happens in
practice.

To avoid this, switch the allocation to kvmalloc() instead; this also
brings fq_impl in line with all the FQ qdiscs.

Fixes: 557fc4a09803 ("fq: add fair queuing framework")
Reported-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
Link: https://lore.kernel.org/r/20191105155750.547379-1-toke@redhat.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>

authored by

Toke Høiland-Jørgensen and committed by
Johannes Berg
71e67c3b 6dd47d97

+2 -2
+2 -2
include/net/fq_impl.h
··· 313 313 fq->limit = 8192; 314 314 fq->memory_limit = 16 << 20; /* 16 MBytes */ 315 315 316 - fq->flows = kcalloc(fq->flows_cnt, sizeof(fq->flows[0]), GFP_KERNEL); 316 + fq->flows = kvcalloc(fq->flows_cnt, sizeof(fq->flows[0]), GFP_KERNEL); 317 317 if (!fq->flows) 318 318 return -ENOMEM; 319 319 ··· 331 331 for (i = 0; i < fq->flows_cnt; i++) 332 332 fq_flow_reset(fq, &fq->flows[i], free_func); 333 333 334 - kfree(fq->flows); 334 + kvfree(fq->flows); 335 335 fq->flows = NULL; 336 336 } 337 337