diff options
Diffstat (limited to 'net/key')
-rw-r--r-- | net/key/af_key.c | 25 |
1 files changed, 6 insertions, 19 deletions
diff --git a/net/key/af_key.c b/net/key/af_key.c index 478c8b32a5fb..84209fbbeb17 100644 --- a/net/key/af_key.c +++ b/net/key/af_key.c | |||
@@ -3765,28 +3765,14 @@ static struct xfrm_mgr pfkeyv2_mgr = | |||
3765 | 3765 | ||
3766 | static int __net_init pfkey_net_init(struct net *net) | 3766 | static int __net_init pfkey_net_init(struct net *net) |
3767 | { | 3767 | { |
3768 | struct netns_pfkey *net_pfkey; | 3768 | struct netns_pfkey *net_pfkey = net_generic(net, pfkey_net_id); |
3769 | int rv; | 3769 | int rv; |
3770 | 3770 | ||
3771 | net_pfkey = kmalloc(sizeof(struct netns_pfkey), GFP_KERNEL); | ||
3772 | if (!net_pfkey) { | ||
3773 | rv = -ENOMEM; | ||
3774 | goto out_kmalloc; | ||
3775 | } | ||
3776 | INIT_HLIST_HEAD(&net_pfkey->table); | 3771 | INIT_HLIST_HEAD(&net_pfkey->table); |
3777 | atomic_set(&net_pfkey->socks_nr, 0); | 3772 | atomic_set(&net_pfkey->socks_nr, 0); |
3778 | rv = net_assign_generic(net, pfkey_net_id, net_pfkey); | 3773 | |
3779 | if (rv < 0) | ||
3780 | goto out_assign; | ||
3781 | rv = pfkey_init_proc(net); | 3774 | rv = pfkey_init_proc(net); |
3782 | if (rv < 0) | ||
3783 | goto out_proc; | ||
3784 | return 0; | ||
3785 | 3775 | ||
3786 | out_proc: | ||
3787 | out_assign: | ||
3788 | kfree(net_pfkey); | ||
3789 | out_kmalloc: | ||
3790 | return rv; | 3776 | return rv; |
3791 | } | 3777 | } |
3792 | 3778 | ||
@@ -3796,17 +3782,18 @@ static void __net_exit pfkey_net_exit(struct net *net) | |||
3796 | 3782 | ||
3797 | pfkey_exit_proc(net); | 3783 | pfkey_exit_proc(net); |
3798 | BUG_ON(!hlist_empty(&net_pfkey->table)); | 3784 | BUG_ON(!hlist_empty(&net_pfkey->table)); |
3799 | kfree(net_pfkey); | ||
3800 | } | 3785 | } |
3801 | 3786 | ||
3802 | static struct pernet_operations pfkey_net_ops = { | 3787 | static struct pernet_operations pfkey_net_ops = { |
3803 | .init = pfkey_net_init, | 3788 | .init = pfkey_net_init, |
3804 | .exit = pfkey_net_exit, | 3789 | .exit = pfkey_net_exit, |
3790 | .id = &pfkey_net_id, | ||
3791 | .size = sizeof(struct netns_pfkey), | ||
3805 | }; | 3792 | }; |
3806 | 3793 | ||
3807 | static void __exit ipsec_pfkey_exit(void) | 3794 | static void __exit ipsec_pfkey_exit(void) |
3808 | { | 3795 | { |
3809 | unregister_pernet_gen_subsys(pfkey_net_id, &pfkey_net_ops); | 3796 | unregister_pernet_subsys(&pfkey_net_ops); |
3810 | xfrm_unregister_km(&pfkeyv2_mgr); | 3797 | xfrm_unregister_km(&pfkeyv2_mgr); |
3811 | sock_unregister(PF_KEY); | 3798 | sock_unregister(PF_KEY); |
3812 | proto_unregister(&key_proto); | 3799 | proto_unregister(&key_proto); |
@@ -3825,7 +3812,7 @@ static int __init ipsec_pfkey_init(void) | |||
3825 | err = xfrm_register_km(&pfkeyv2_mgr); | 3812 | err = xfrm_register_km(&pfkeyv2_mgr); |
3826 | if (err != 0) | 3813 | if (err != 0) |
3827 | goto out_sock_unregister; | 3814 | goto out_sock_unregister; |
3828 | err = register_pernet_gen_subsys(&pfkey_net_id, &pfkey_net_ops); | 3815 | err = register_pernet_subsys(&pfkey_net_ops); |
3829 | if (err != 0) | 3816 | if (err != 0) |
3830 | goto out_xfrm_unregister_km; | 3817 | goto out_xfrm_unregister_km; |
3831 | out: | 3818 | out: |