Commit 734b65417b24d6eea3e3d7457e1f11493890ee1d

Authored by Rustad, Mark D
Committed by David S. Miller
1 parent 2ab1c24bbd

net: Statically initialize init_net.dev_base_head

This change eliminates an initialization-order hazard most
recently seen when netprio_cgroup is built into the kernel.

With thanks to Eric Dumazet for catching a bug.

Signed-off-by: Mark Rustad <mark.d.rustad@intel.com>
Acked-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

Showing 2 changed files with 5 additions and 2 deletions Side-by-side Diff

... ... @@ -6283,7 +6283,8 @@
6283 6283 /* Initialize per network namespace state */
6284 6284 static int __net_init netdev_init(struct net *net)
6285 6285 {
6286   - INIT_LIST_HEAD(&net->dev_base_head);
  6286 + if (net != &init_net)
  6287 + INIT_LIST_HEAD(&net->dev_base_head);
6287 6288  
6288 6289 net->dev_name_head = netdev_create_hash();
6289 6290 if (net->dev_name_head == NULL)
net/core/net_namespace.c
... ... @@ -27,7 +27,9 @@
27 27 LIST_HEAD(net_namespace_list);
28 28 EXPORT_SYMBOL_GPL(net_namespace_list);
29 29  
30   -struct net init_net;
  30 +struct net init_net = {
  31 + .dev_base_head = LIST_HEAD_INIT(init_net.dev_base_head),
  32 +};
31 33 EXPORT_SYMBOL(init_net);
32 34  
33 35 #define INITIAL_NET_GEN_PTRS 13 /* +1 for len +2 for rcu_head */