Skip to contentSkip to conversation

Net: netfilter: vmalloc/vfree to kvmalloc/kvfree

PATCH New Charlie Sale 1 participant 1 message Nov 19, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Net: netfilter: vmalloc/vfree to kvmalloc/kvfree

Fixed FIXME by changing memory allocation and freeing in htable_create to kvmalloc and kvfree from vmalloc and vfree. Changes are made throughout the file in order to account for the different allocation of htable_create.

---
 net/netfilter/xt_hashlimit.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
net/netfilter/xt_hashlimit.c +6 -6
index 5da8746f7b88..444f57f25d77 100644
@@ -286,9 +286,9 @@ static int htable_create(struct net *net, struct hashlimit_cfg3 *cfg,
 		if (size < 16)
 			size = 16;
 	}
-	/* FIXME: don't use vmalloc() here or anywhere else -HW */
-	hinfo = vmalloc(sizeof(struct xt_hashlimit_htable) +
-	                sizeof(struct hlist_head) * size);
+
+	hinfo = kvmalloc(sizeof(*hinfo) + sizeof(struct hlist_head) * size,
+			 GFP_KERNEL);
 	if (hinfo == NULL)
 		return -ENOMEM;
 	*out_hinfo = hinfo;
@@ -314,7 +314,7 @@ static int htable_create(struct net *net, struct hashlimit_cfg3 *cfg,
 	hinfo->rnd_initialized = false;
 	hinfo->name = kstrdup(name, GFP_KERNEL);
 	if (!hinfo->name) {
-		vfree(hinfo);
+		kvfree(hinfo);
 		return -ENOMEM;
 	}
 	spin_lock_init(&hinfo->lock);
@@ -336,7 +336,7 @@ static int htable_create(struct net *net, struct hashlimit_cfg3 *cfg,
 		fops, hinfo);
 	if (hinfo->pde == NULL) {
 		kfree(hinfo->name);
-		vfree(hinfo);
+		kvfree(hinfo);
 		return -ENOMEM;
 	}
 	hinfo->net = net;
@@ -414,7 +414,7 @@ static void htable_destroy(struct xt_hashlimit_htable *hinfo)
 	htable_remove_proc_entry(hinfo);
 	htable_selective_cleanup(hinfo, select_all);
 	kfree(hinfo->name);
-	vfree(hinfo);
+	kvfree(hinfo);
 }
 
 static struct xt_hashlimit_htable *htable_find_get(struct net *net,
Signature · 1 line
2.13.6