* [PATCH] NETLINK : kzalloc() conversion
@ 2007-12-11 5:40 Eric Dumazet
2007-12-11 5:43 ` YOSHIFUJI Hideaki / 吉藤英明
0 siblings, 1 reply; 3+ messages in thread
From: Eric Dumazet @ 2007-12-11 5:40 UTC (permalink / raw)
To: David S. Miller; +Cc: Linux Netdev List
[-- Attachment #1: Type: text/plain, Size: 157 bytes --]
nl_pid_hash_alloc() is renamed to nl_pid_hash_zalloc().
It is now returning zeroed memory to its callers.
Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>
[-- Attachment #2: netlink.patch --]
[-- Type: text/plain, Size: 1574 bytes --]
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index 2e02b19..dbd7cad 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -237,13 +237,14 @@ found:
return sk;
}
-static inline struct hlist_head *nl_pid_hash_alloc(size_t size)
+static inline struct hlist_head *nl_pid_hash_zalloc(size_t size)
{
if (size <= PAGE_SIZE)
- return kmalloc(size, GFP_ATOMIC);
+ return kzalloc(size, GFP_ATOMIC);
else
return (struct hlist_head *)
- __get_free_pages(GFP_ATOMIC, get_order(size));
+ __get_free_pages(GFP_ATOMIC | __GFP_ZERO,
+ get_order(size));
}
static inline void nl_pid_hash_free(struct hlist_head *table, size_t size)
@@ -272,11 +273,10 @@ static int nl_pid_hash_rehash(struct nl_pid_hash *hash, int grow)
size *= 2;
}
- table = nl_pid_hash_alloc(size);
+ table = nl_pid_hash_zalloc(size);
if (!table)
return 0;
- memset(table, 0, size);
otable = hash->table;
hash->table = table;
hash->mask = mask;
@@ -1919,7 +1919,7 @@ static int __init netlink_proto_init(void)
for (i = 0; i < MAX_LINKS; i++) {
struct nl_pid_hash *hash = &nl_table[i].hash;
- hash->table = nl_pid_hash_alloc(1 * sizeof(*hash->table));
+ hash->table = nl_pid_hash_zalloc(1 * sizeof(*hash->table));
if (!hash->table) {
while (i-- > 0)
nl_pid_hash_free(nl_table[i].hash.table,
@@ -1927,7 +1927,6 @@ static int __init netlink_proto_init(void)
kfree(nl_table);
goto panic;
}
- memset(hash->table, 0, 1 * sizeof(*hash->table));
hash->max_shift = order;
hash->shift = 0;
hash->mask = 0;
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] NETLINK : kzalloc() conversion
2007-12-11 5:40 [PATCH] NETLINK : kzalloc() conversion Eric Dumazet
@ 2007-12-11 5:43 ` YOSHIFUJI Hideaki / 吉藤英明
2007-12-11 5:46 ` Eric Dumazet
0 siblings, 1 reply; 3+ messages in thread
From: YOSHIFUJI Hideaki / 吉藤英明 @ 2007-12-11 5:43 UTC (permalink / raw)
To: dada1; +Cc: davem, netdev, yoshfuji
In article <475E22C2.9050700@cosmosbay.com> (at Tue, 11 Dec 2007 06:40:18 +0100), Eric Dumazet <dada1@cosmosbay.com> says:
> nl_pid_hash_alloc() is renamed to nl_pid_hash_zalloc().
> It is now returning zeroed memory to its callers.
I do think you do not need (and you should not) rename it
because XXX_zalloc() would imply we have raw XXX_alloc().
--yoshfuji
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] NETLINK : kzalloc() conversion
2007-12-11 5:43 ` YOSHIFUJI Hideaki / 吉藤英明
@ 2007-12-11 5:46 ` Eric Dumazet
0 siblings, 0 replies; 3+ messages in thread
From: Eric Dumazet @ 2007-12-11 5:46 UTC (permalink / raw)
To: YOSHIFUJI Hideaki / 吉藤英明; +Cc: davem, netdev
YOSHIFUJI Hideaki / 吉藤英明 a écrit :
> In article <475E22C2.9050700@cosmosbay.com> (at Tue, 11 Dec 2007 06:40:18 +0100), Eric Dumazet <dada1@cosmosbay.com> says:
>
>> nl_pid_hash_alloc() is renamed to nl_pid_hash_zalloc().
>> It is now returning zeroed memory to its callers.
>
> I do think you do not need (and you should not) rename it
> because XXX_zalloc() would imply we have raw XXX_alloc().
>
Well, its a static function, so a single grep should satisfy
reader's concern :)
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-12-11 5:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-12-11 5:40 [PATCH] NETLINK : kzalloc() conversion Eric Dumazet
2007-12-11 5:43 ` YOSHIFUJI Hideaki / 吉藤英明
2007-12-11 5:46 ` Eric Dumazet
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).