netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] ip: initialize hash list
@ 2013-07-20 17:26 Stephen Hemminger
  2013-07-20 17:46 ` Joe Perches
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Stephen Hemminger @ 2013-07-20 17:26 UTC (permalink / raw)
  To: Pravin B Shelar, David Miller; +Cc: netdev

Rather than relying on the assumption that zero means empty on
hash list head, the code should use the initialization macro.
Same effect, but follows API and avoids future breakage if hlist
implementation changes.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>


--- a/net/ipv4/ip_tunnel.c	2013-07-19 09:12:37.213529343 -0700
+++ b/net/ipv4/ip_tunnel.c	2013-07-19 09:37:00.960764421 -0700
@@ -838,10 +838,15 @@ int ip_tunnel_init_net(struct net *net,
 {
 	struct ip_tunnel_net *itn = net_generic(net, ip_tnl_net_id);
 	struct ip_tunnel_parm parms;
+	unsigned i;
 
-	itn->tunnels = kzalloc(IP_TNL_HASH_SIZE * sizeof(struct hlist_head), GFP_KERNEL);
+	itn->tunnels = kmalloc(IP_TNL_HASH_SIZE * sizeof(struct hlist_head),
+			       GFP_KERNEL);
 	if (!itn->tunnels)
 		return -ENOMEM;
+
+	for (i = 0; i < IP_TNL_HASH_SIZE; i++)
+		INIT_HLIST_HEAD(&itn->tunnels[i]);
 
 	if (!ops) {
 		itn->fb_tunnel_dev = NULL;

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2013-07-22 15:31 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-20 17:26 [PATCH net-next] ip: initialize hash list Stephen Hemminger
2013-07-20 17:46 ` Joe Perches
2013-07-22 14:52   ` Stephen Hemminger
2013-07-22 15:06     ` Joe Perches
2013-07-22 15:15       ` Eric Dumazet
2013-07-22 15:31         ` Joe Perches
2013-07-20 19:20 ` David Miller
2013-07-20 20:28   ` Joe Perches
2013-07-22 15:17 ` 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).