aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc
diff options
context:
space:
mode:
authorJunwei Hu <hujunwei4@huawei.com>2019-05-17 07:27:34 -0400
committerDavid S. Miller <davem@davemloft.net>2019-05-17 14:33:51 -0400
commit532b0f7ece4cb2ffd24dc723ddf55242d1188e5e (patch)
treed428501ce602df759779cfc11cff1e1e0e4c1802 /net/tipc
parent38a04b83ab3033905114d608737504e66350088b (diff)
tipc: fix modprobe tipc failed after switch order of device registration
Error message printed: modprobe: ERROR: could not insert 'tipc': Address family not supported by protocol. when modprobe tipc after the following patch: switch order of device registration, commit 7e27e8d6130c ("tipc: switch order of device registration to fix a crash") Because sock_create_kern(net, AF_TIPC, ...) is called by tipc_topsrv_create_listener() in the initialization process of tipc_net_ops, tipc_socket_init() must be execute before that. I move tipc_socket_init() into function tipc_init_net(). Fixes: 7e27e8d6130c ("tipc: switch order of device registration to fix a crash") Signed-off-by: Junwei Hu <hujunwei4@huawei.com> Reported-by: Wang Wang <wangwang2@huawei.com> Reviewed-by: Kang Zhou <zhoukang7@huawei.com> Reviewed-by: Suanming Mou <mousuanming@huawei.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tipc')
-rw-r--r--net/tipc/core.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/net/tipc/core.c b/net/tipc/core.c
index ddd2e0f67c07..7d05d6823545 100644
--- a/net/tipc/core.c
+++ b/net/tipc/core.c
@@ -68,6 +68,10 @@ static int __net_init tipc_init_net(struct net *net)
68 INIT_LIST_HEAD(&tn->node_list); 68 INIT_LIST_HEAD(&tn->node_list);
69 spin_lock_init(&tn->node_list_lock); 69 spin_lock_init(&tn->node_list_lock);
70 70
71 err = tipc_socket_init();
72 if (err)
73 goto out_socket;
74
71 err = tipc_sk_rht_init(net); 75 err = tipc_sk_rht_init(net);
72 if (err) 76 if (err)
73 goto out_sk_rht; 77 goto out_sk_rht;
@@ -94,6 +98,8 @@ out_subscr:
94out_nametbl: 98out_nametbl:
95 tipc_sk_rht_destroy(net); 99 tipc_sk_rht_destroy(net);
96out_sk_rht: 100out_sk_rht:
101 tipc_socket_stop();
102out_socket:
97 return err; 103 return err;
98} 104}
99 105
@@ -104,6 +110,7 @@ static void __net_exit tipc_exit_net(struct net *net)
104 tipc_bcast_stop(net); 110 tipc_bcast_stop(net);
105 tipc_nametbl_stop(net); 111 tipc_nametbl_stop(net);
106 tipc_sk_rht_destroy(net); 112 tipc_sk_rht_destroy(net);
113 tipc_socket_stop();
107} 114}
108 115
109static struct pernet_operations tipc_net_ops = { 116static struct pernet_operations tipc_net_ops = {
@@ -139,10 +146,6 @@ static int __init tipc_init(void)
139 if (err) 146 if (err)
140 goto out_pernet; 147 goto out_pernet;
141 148
142 err = tipc_socket_init();
143 if (err)
144 goto out_socket;
145
146 err = tipc_bearer_setup(); 149 err = tipc_bearer_setup();
147 if (err) 150 if (err)
148 goto out_bearer; 151 goto out_bearer;
@@ -150,8 +153,6 @@ static int __init tipc_init(void)
150 pr_info("Started in single node mode\n"); 153 pr_info("Started in single node mode\n");
151 return 0; 154 return 0;
152out_bearer: 155out_bearer:
153 tipc_socket_stop();
154out_socket:
155 unregister_pernet_subsys(&tipc_net_ops); 156 unregister_pernet_subsys(&tipc_net_ops);
156out_pernet: 157out_pernet:
157 tipc_unregister_sysctl(); 158 tipc_unregister_sysctl();
@@ -167,7 +168,6 @@ out_netlink:
167static void __exit tipc_exit(void) 168static void __exit tipc_exit(void)
168{ 169{
169 tipc_bearer_cleanup(); 170 tipc_bearer_cleanup();
170 tipc_socket_stop();
171 unregister_pernet_subsys(&tipc_net_ops); 171 unregister_pernet_subsys(&tipc_net_ops);
172 tipc_netlink_stop(); 172 tipc_netlink_stop();
173 tipc_netlink_compat_stop(); 173 tipc_netlink_compat_stop();