* [PATCH] Net: netfilter: vmalloc/vfree to kvmalloc/kvfree
@ 2017-11-03 20:07 Charlie Sale
2017-11-04 0:19 ` Florian Westphal
0 siblings, 1 reply; 3+ messages in thread
From: Charlie Sale @ 2017-11-03 20:07 UTC (permalink / raw)
To: pablo; +Cc: netfilter-devel, netdev, linux-kernel, Charlie Sale
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.
Small note: This is a replacement of an earlier patch that did not
work. Enough was changed, so I thought I would just submit a new
patch.
Signed-off-by: Charlie Sale <chucks.8090@gmail.com>
---
net/netfilter/xt_hashlimit.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/net/netfilter/xt_hashlimit.c b/net/netfilter/xt_hashlimit.c
index 5da8746f7b88..28ad74b3e3d0 100644
--- a/net/netfilter/xt_hashlimit.c
+++ b/net/netfilter/xt_hashlimit.c
@@ -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,
+ GPT_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,
--
2.13.6
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] Net: netfilter: vmalloc/vfree to kvmalloc/kvfree
2017-11-03 20:07 [PATCH] Net: netfilter: vmalloc/vfree to kvmalloc/kvfree Charlie Sale
@ 2017-11-04 0:19 ` Florian Westphal
0 siblings, 0 replies; 3+ messages in thread
From: Florian Westphal @ 2017-11-04 0:19 UTC (permalink / raw)
To: Charlie Sale; +Cc: pablo, netfilter-devel, netdev, linux-kernel
Charlie Sale <chucks.8090@gmail.com> wrote:
> + hinfo = kvmalloc(sizeof(*hinfo) + sizeof(struct hlist_head) * size,
> + GPT_KERNEL);
Looks like you did not even compile test this. Again. :-(
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] Net: netfilter: vmalloc/vfree to kvmalloc/kvfree
@ 2017-11-19 17:46 Charlie Sale
0 siblings, 0 replies; 3+ messages in thread
From: Charlie Sale @ 2017-11-19 17:46 UTC (permalink / raw)
To: pablo; +Cc: netfilter-devel, linux-kernel, Charlie Sale
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.
Signed-off-by: Charlie Sale <chucks.8090@gmail.com>
---
net/netfilter/xt_hashlimit.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/net/netfilter/xt_hashlimit.c b/net/netfilter/xt_hashlimit.c
index 5da8746f7b88..444f57f25d77 100644
--- a/net/netfilter/xt_hashlimit.c
+++ b/net/netfilter/xt_hashlimit.c
@@ -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,
--
2.13.6
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-11-19 17:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-03 20:07 [PATCH] Net: netfilter: vmalloc/vfree to kvmalloc/kvfree Charlie Sale
2017-11-04 0:19 ` Florian Westphal
2017-11-19 17:46 Charlie Sale
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).