diff mbox series

Net: netfilter: Moved vmalloc call to kmalloc call

Message ID 20171102231727.12610-1-chucks.8090@gmail.com
State Rejected, archived
Delegated to: David Miller
Headers show
Series Net: netfilter: Moved vmalloc call to kmalloc call | expand

Commit Message

Charlie Sale Nov. 2, 2017, 11:17 p.m. UTC
Fixed FIXME comment in code my changing a vmalloc call
to a kmalloc call. Thought it would be a good place to
start for a first patch.

Signed-off-by: Charlie Sale <chucks.8090@gmail.com>

---
 net/netfilter/xt_hashlimit.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Florian Westphal Nov. 2, 2017, 11:35 p.m. UTC | #1
Charlie Sale <chucks.8090@gmail.com> wrote:
> Fixed FIXME comment in code my changing a vmalloc call
> to a kmalloc call. Thought it would be a good place to
> start for a first patch.

Please at least compile test your patches.

> -	/* FIXME: don't use vmalloc() here or anywhere else -HW */
> -	hinfo = vmalloc(sizeof(struct xt_hashlimit_htable) +
> -	                sizeof(struct hlist_head) * size);
> +
> +	hinfo = kmalloc(sizeof(*hinfo) +
> +			sizeof(struct hlist_head) * size, GPT_KERNEL);

If anything this should be switched to kvmalloc, not kmalloc.

Also, hinfo cannot be free'd via vfree after this change, so you need to
adjust all free operations too.
David Miller Nov. 3, 2017, 12:59 a.m. UTC | #2
From: Charlie Sale <chucks.8090@gmail.com>
Date: Thu,  2 Nov 2017 19:17:27 -0400

> Fixed FIXME comment in code my changing a vmalloc call
> to a kmalloc call. Thought it would be a good place to
> start for a first patch.
> 
> Signed-off-by: Charlie Sale <chucks.8090@gmail.com>

Since this code you are posting doesn't even compile, we have to
assume you didn't functionally test it either.
diff mbox series

Patch

diff --git a/net/netfilter/xt_hashlimit.c b/net/netfilter/xt_hashlimit.c
index 5da8746f7b88..4eab1befe03c 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 = kmalloc(sizeof(*hinfo) +
+			sizeof(struct hlist_head) * size, GPT_KERNEL);
 	if (hinfo == NULL)
 		return -ENOMEM;
 	*out_hinfo = hinfo;