Skip to contentSkip to conversation

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

PATCH New Toke Høiland-Jørgensen 1 participant 1 message Nov 5, 2019 Networking

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 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")

---
v2:
- Also change kfree()->kvfree()

 include/net/fq_impl.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/net/fq_impl.h +2 -2
index 107c0d700ed6..38a9a3d1222b 100644
@@ -313,7 +313,7 @@ static int fq_init(struct fq *fq, int flows_cnt)
 	fq->limit = 8192;
 	fq->memory_limit = 16 << 20; /* 16 MBytes */
 
-	fq->flows = kcalloc(fq->flows_cnt, sizeof(fq->flows[0]), GFP_KERNEL);
+	fq->flows = kvcalloc(fq->flows_cnt, sizeof(fq->flows[0]), GFP_KERNEL);
 	if (!fq->flows)
 		return -ENOMEM;
 
@@ -331,7 +331,7 @@ static void fq_reset(struct fq *fq,
 	for (i = 0; i < fq->flows_cnt; i++)
 		fq_flow_reset(fq, &fq->flows[i], free_func);
 
-	kfree(fq->flows);
+	kvfree(fq->flows);
 	fq->flows = NULL;
 }
 
Signature · 1 line
2.23.0