* [PATCH 3/4] fib_hash: kmalloc + memset conversion to kzalloc
@ 2007-11-26 9:02 Joonwoo Park
0 siblings, 0 replies; 3+ messages in thread
From: Joonwoo Park @ 2007-11-26 9:02 UTC (permalink / raw)
To: netdev; +Cc: linux-kernel
fib_hash: kmalloc + memset conversion to kzalloc
Signed-off-by: Joonwoo Park <joonwpark81@gmail.com>
Thanks.
Joonwoo
---
diff --git a/net/ipv4/fib_hash.c b/net/ipv4/fib_hash.c
index 527a6e0..2874fe7 100644
--- a/net/ipv4/fib_hash.c
+++ b/net/ipv4/fib_hash.c
@@ -102,10 +102,14 @@ static struct hlist_head *fz_hash_alloc(int divisor)
unsigned long size = divisor * sizeof(struct hlist_head);
if (size <= PAGE_SIZE) {
- return kmalloc(size, GFP_KERNEL);
+ return kzalloc(size, GFP_KERNEL);
} else {
- return (struct hlist_head *)
+ struct hlist_head *hash;
+ hash = (struct hlist_head *)
__get_free_pages(GFP_KERNEL, get_order(size));
+ if (hash)
+ memset(hash, 0, size);
+ return hash;
}
}
@@ -174,8 +178,6 @@ static void fn_rehash_zone(struct fn_zone *fz)
ht = fz_hash_alloc(new_divisor);
if (ht) {
- memset(ht, 0, new_divisor * sizeof(struct hlist_head));
-
write_lock_bh(&fib_hash_lock);
old_ht = fz->fz_hash;
fz->fz_hash = ht;
@@ -219,7 +221,6 @@ fn_new_zone(struct fn_hash *table, int z)
kfree(fz);
return NULL;
}
- memset(fz->fz_hash, 0, fz->fz_divisor * sizeof(struct hlist_head *));
fz->fz_order = z;
fz->fz_mask = inet_make_mask(z);
---
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 3/4] fib_hash: kmalloc + memset conversion to kzalloc
@ 2007-11-26 10:24 Joonwoo Park
2007-11-26 15:31 ` Herbert Xu
0 siblings, 1 reply; 3+ messages in thread
From: Joonwoo Park @ 2007-11-26 10:24 UTC (permalink / raw)
To: netdev; +Cc: linux-kernel
fib_hash: kmalloc + memset conversion to kzalloc
fix to avoid memset entirely.
Thanks.
Joonwoo
Signed-off-by: Joonwoo Park <joonwpark81@gmail.com>
---
diff --git a/net/ipv4/fib_hash.c b/net/ipv4/fib_hash.c
index 527a6e0..9d0cee2 100644
--- a/net/ipv4/fib_hash.c
+++ b/net/ipv4/fib_hash.c
@@ -102,10 +102,10 @@ static struct hlist_head *fz_hash_alloc(int divisor)
unsigned long size = divisor * sizeof(struct hlist_head);
if (size <= PAGE_SIZE) {
- return kmalloc(size, GFP_KERNEL);
+ return kzalloc(size, GFP_KERNEL);
} else {
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)
ht = fz_hash_alloc(new_divisor);
if (ht) {
- memset(ht, 0, new_divisor * sizeof(struct hlist_head));
-
write_lock_bh(&fib_hash_lock);
old_ht = fz->fz_hash;
fz->fz_hash = ht;
@@ -219,7 +217,6 @@ fn_new_zone(struct fn_hash *table, int z)
kfree(fz);
return NULL;
}
- memset(fz->fz_hash, 0, fz->fz_divisor * sizeof(struct hlist_head *));
fz->fz_order = z;
fz->fz_mask = inet_make_mask(z);
---
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 3/4] fib_hash: kmalloc + memset conversion to kzalloc
2007-11-26 10:24 Joonwoo Park
@ 2007-11-26 15:31 ` Herbert Xu
0 siblings, 0 replies; 3+ messages in thread
From: Herbert Xu @ 2007-11-26 15:31 UTC (permalink / raw)
To: Joonwoo Park; +Cc: netdev, linux-kernel
On Mon, Nov 26, 2007 at 10:24:03AM +0000, Joonwoo Park wrote:
> fib_hash: kmalloc + memset conversion to kzalloc
> fix to avoid memset entirely.
Patch applied.
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-11-26 15:31 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-26 9:02 [PATCH 3/4] fib_hash: kmalloc + memset conversion to kzalloc Joonwoo Park
-- strict thread matches above, loose matches on Subject: below --
2007-11-26 10:24 Joonwoo Park
2007-11-26 15:31 ` Herbert Xu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox