提交 3015a347 编写于 作者: J Joonwoo Park 提交者: David S. Miller

[IPV4] fib_hash: kmalloc + memset conversion to kzalloc

fib_hash: kmalloc + memset conversion to kzalloc
fix to avoid memset entirely.
Signed-off-by: NJoonwoo Park <joonwpark81@gmail.com>
Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 88f83491
...@@ -102,10 +102,10 @@ static struct hlist_head *fz_hash_alloc(int divisor) ...@@ -102,10 +102,10 @@ static struct hlist_head *fz_hash_alloc(int divisor)
unsigned long size = divisor * sizeof(struct hlist_head); unsigned long size = divisor * sizeof(struct hlist_head);
if (size <= PAGE_SIZE) { if (size <= PAGE_SIZE) {
return kmalloc(size, GFP_KERNEL); return kzalloc(size, GFP_KERNEL);
} else { } else {
return (struct hlist_head *) return (struct hlist_head *)
__get_free_pages(GFP_KERNEL, get_order(size)); __get_free_pages(GFP_KERNEL | __GFP_ZERO, get_order(size));
} }
} }
...@@ -174,8 +174,6 @@ static void fn_rehash_zone(struct fn_zone *fz) ...@@ -174,8 +174,6 @@ static void fn_rehash_zone(struct fn_zone *fz)
ht = fz_hash_alloc(new_divisor); ht = fz_hash_alloc(new_divisor);
if (ht) { if (ht) {
memset(ht, 0, new_divisor * sizeof(struct hlist_head));
write_lock_bh(&fib_hash_lock); write_lock_bh(&fib_hash_lock);
old_ht = fz->fz_hash; old_ht = fz->fz_hash;
fz->fz_hash = ht; fz->fz_hash = ht;
...@@ -219,7 +217,6 @@ fn_new_zone(struct fn_hash *table, int z) ...@@ -219,7 +217,6 @@ fn_new_zone(struct fn_hash *table, int z)
kfree(fz); kfree(fz);
return NULL; return NULL;
} }
memset(fz->fz_hash, 0, fz->fz_divisor * sizeof(struct hlist_head *));
fz->fz_order = z; fz->fz_order = z;
fz->fz_mask = inet_make_mask(z); fz->fz_mask = inet_make_mask(z);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册