netfilter: xt_hashlimit: alloc hashtable with right size
struct xt_byteslimit_htable used hlist_head, but memory allocation is done through sizeof(struct list_head). Signed-off-by: Zhizhou Tian <zhizhou.tian@gmail.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
This commit is contained in:
parent
74585d4f84
commit
05d0eae7c1
|
@ -279,7 +279,7 @@ static int htable_create(struct net *net, struct hashlimit_cfg3 *cfg,
|
||||||
size = cfg->size;
|
size = cfg->size;
|
||||||
} else {
|
} else {
|
||||||
size = (totalram_pages << PAGE_SHIFT) / 16384 /
|
size = (totalram_pages << PAGE_SHIFT) / 16384 /
|
||||||
sizeof(struct list_head);
|
sizeof(struct hlist_head);
|
||||||
if (totalram_pages > 1024 * 1024 * 1024 / PAGE_SIZE)
|
if (totalram_pages > 1024 * 1024 * 1024 / PAGE_SIZE)
|
||||||
size = 8192;
|
size = 8192;
|
||||||
if (size < 16)
|
if (size < 16)
|
||||||
|
@ -287,7 +287,7 @@ static int htable_create(struct net *net, struct hashlimit_cfg3 *cfg,
|
||||||
}
|
}
|
||||||
/* FIXME: don't use vmalloc() here or anywhere else -HW */
|
/* FIXME: don't use vmalloc() here or anywhere else -HW */
|
||||||
hinfo = vmalloc(sizeof(struct xt_hashlimit_htable) +
|
hinfo = vmalloc(sizeof(struct xt_hashlimit_htable) +
|
||||||
sizeof(struct list_head) * size);
|
sizeof(struct hlist_head) * size);
|
||||||
if (hinfo == NULL)
|
if (hinfo == NULL)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
*out_hinfo = hinfo;
|
*out_hinfo = hinfo;
|
||||||
|
|
Loading…
Reference in New Issue