aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/ip_tunnel.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/ipv4/ip_tunnel.c')
-rw-r--r--net/ipv4/ip_tunnel.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c
index ca1cb2d5f6e2..9fdf8a6d95f3 100644
--- a/net/ipv4/ip_tunnel.c
+++ b/net/ipv4/ip_tunnel.c
@@ -838,15 +838,16 @@ int ip_tunnel_init_net(struct net *net, int ip_tnl_net_id,
838{ 838{
839 struct ip_tunnel_net *itn = net_generic(net, ip_tnl_net_id); 839 struct ip_tunnel_net *itn = net_generic(net, ip_tnl_net_id);
840 struct ip_tunnel_parm parms; 840 struct ip_tunnel_parm parms;
841 unsigned int i;
841 842
842 itn->tunnels = kzalloc(IP_TNL_HASH_SIZE * sizeof(struct hlist_head), GFP_KERNEL); 843 for (i = 0; i < IP_TNL_HASH_SIZE; i++)
843 if (!itn->tunnels) 844 INIT_HLIST_HEAD(&itn->tunnels[i]);
844 return -ENOMEM;
845 845
846 if (!ops) { 846 if (!ops) {
847 itn->fb_tunnel_dev = NULL; 847 itn->fb_tunnel_dev = NULL;
848 return 0; 848 return 0;
849 } 849 }
850
850 memset(&parms, 0, sizeof(parms)); 851 memset(&parms, 0, sizeof(parms));
851 if (devname) 852 if (devname)
852 strlcpy(parms.name, devname, IFNAMSIZ); 853 strlcpy(parms.name, devname, IFNAMSIZ);
@@ -854,10 +855,9 @@ int ip_tunnel_init_net(struct net *net, int ip_tnl_net_id,
854 rtnl_lock(); 855 rtnl_lock();
855 itn->fb_tunnel_dev = __ip_tunnel_create(net, ops, &parms); 856 itn->fb_tunnel_dev = __ip_tunnel_create(net, ops, &parms);
856 rtnl_unlock(); 857 rtnl_unlock();
857 if (IS_ERR(itn->fb_tunnel_dev)) { 858
858 kfree(itn->tunnels); 859 if (IS_ERR(itn->fb_tunnel_dev))
859 return PTR_ERR(itn->fb_tunnel_dev); 860 return PTR_ERR(itn->fb_tunnel_dev);
860 }
861 861
862 return 0; 862 return 0;
863} 863}
@@ -887,7 +887,6 @@ void ip_tunnel_delete_net(struct ip_tunnel_net *itn)
887 ip_tunnel_destroy(itn, &list); 887 ip_tunnel_destroy(itn, &list);
888 unregister_netdevice_many(&list); 888 unregister_netdevice_many(&list);
889 rtnl_unlock(); 889 rtnl_unlock();
890 kfree(itn->tunnels);
891} 890}
892EXPORT_SYMBOL_GPL(ip_tunnel_delete_net); 891EXPORT_SYMBOL_GPL(ip_tunnel_delete_net);
893 892