Skip to content

Commit

Permalink
net: fib_rules ordering fixes.
Browse files Browse the repository at this point in the history
We need to setup the network namespace state before we register
the notifier.  Otherwise if a network device is already registered
we get a nasty NULL pointer dereference.

Signed-off-by: Eric W. Biederman <ebiederm@maxwell.aristanetworks.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Eric W. Biederman authored and David S. Miller committed Nov 8, 2008
1 parent 3d8160b commit 5d6d480
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions net/core/fib_rules.c
Original file line number Diff line number Diff line change
Expand Up @@ -664,17 +664,18 @@ static int __init fib_rules_init(void)
rtnl_register(PF_UNSPEC, RTM_DELRULE, fib_nl_delrule, NULL);
rtnl_register(PF_UNSPEC, RTM_GETRULE, NULL, fib_nl_dumprule);

err = register_netdevice_notifier(&fib_rules_notifier);
err = register_pernet_subsys(&fib_rules_net_ops);
if (err < 0)
goto fail;

err = register_pernet_subsys(&fib_rules_net_ops);
err = register_netdevice_notifier(&fib_rules_notifier);
if (err < 0)
goto fail_unregister;

return 0;

fail_unregister:
unregister_netdevice_notifier(&fib_rules_notifier);
unregister_pernet_subsys(&fib_rules_net_ops);
fail:
rtnl_unregister(PF_UNSPEC, RTM_NEWRULE);
rtnl_unregister(PF_UNSPEC, RTM_DELRULE);
Expand Down

0 comments on commit 5d6d480

Please sign in to comment.