提交 ea72912c 编写于 作者: E Eric Dumazet 提交者: David S. Miller

[NETLINK]: kzalloc() conversion

nl_pid_hash_alloc() is renamed to nl_pid_hash_zalloc().
It is now returning zeroed memory to its callers.
Signed-off-by: NEric Dumazet <dada1@cosmosbay.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 64b7d961
...@@ -237,13 +237,14 @@ static inline struct sock *netlink_lookup(struct net *net, int protocol, ...@@ -237,13 +237,14 @@ static inline struct sock *netlink_lookup(struct net *net, int protocol,
return sk; 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) if (size <= PAGE_SIZE)
return kmalloc(size, GFP_ATOMIC); return kzalloc(size, GFP_ATOMIC);
else else
return (struct hlist_head *) 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) 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) ...@@ -272,11 +273,10 @@ static int nl_pid_hash_rehash(struct nl_pid_hash *hash, int grow)
size *= 2; size *= 2;
} }
table = nl_pid_hash_alloc(size); table = nl_pid_hash_zalloc(size);
if (!table) if (!table)
return 0; return 0;
memset(table, 0, size);
otable = hash->table; otable = hash->table;
hash->table = table; hash->table = table;
hash->mask = mask; hash->mask = mask;
...@@ -1919,7 +1919,7 @@ static int __init netlink_proto_init(void) ...@@ -1919,7 +1919,7 @@ static int __init netlink_proto_init(void)
for (i = 0; i < MAX_LINKS; i++) { for (i = 0; i < MAX_LINKS; i++) {
struct nl_pid_hash *hash = &nl_table[i].hash; 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) { if (!hash->table) {
while (i-- > 0) while (i-- > 0)
nl_pid_hash_free(nl_table[i].hash.table, nl_pid_hash_free(nl_table[i].hash.table,
...@@ -1927,7 +1927,6 @@ static int __init netlink_proto_init(void) ...@@ -1927,7 +1927,6 @@ static int __init netlink_proto_init(void)
kfree(nl_table); kfree(nl_table);
goto panic; goto panic;
} }
memset(hash->table, 0, 1 * sizeof(*hash->table));
hash->max_shift = order; hash->max_shift = order;
hash->shift = 0; hash->shift = 0;
hash->mask = 0; hash->mask = 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册