Skip to content

Commit 532b0f7

Browse files
Junwei Hudavem330
authored andcommitted
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 7e27e8d ("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: 7e27e8d ("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>
1 parent 38a04b8 commit 532b0f7

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

net/tipc/core.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ static int __net_init tipc_init_net(struct net *net)
6868
INIT_LIST_HEAD(&tn->node_list);
6969
spin_lock_init(&tn->node_list_lock);
7070

71+
err = tipc_socket_init();
72+
if (err)
73+
goto out_socket;
74+
7175
err = tipc_sk_rht_init(net);
7276
if (err)
7377
goto out_sk_rht;
@@ -94,6 +98,8 @@ static int __net_init tipc_init_net(struct net *net)
9498
out_nametbl:
9599
tipc_sk_rht_destroy(net);
96100
out_sk_rht:
101+
tipc_socket_stop();
102+
out_socket:
97103
return err;
98104
}
99105

@@ -104,6 +110,7 @@ static void __net_exit tipc_exit_net(struct net *net)
104110
tipc_bcast_stop(net);
105111
tipc_nametbl_stop(net);
106112
tipc_sk_rht_destroy(net);
113+
tipc_socket_stop();
107114
}
108115

109116
static struct pernet_operations tipc_net_ops = {
@@ -139,19 +146,13 @@ static int __init tipc_init(void)
139146
if (err)
140147
goto out_pernet;
141148

142-
err = tipc_socket_init();
143-
if (err)
144-
goto out_socket;
145-
146149
err = tipc_bearer_setup();
147150
if (err)
148151
goto out_bearer;
149152

150153
pr_info("Started in single node mode\n");
151154
return 0;
152155
out_bearer:
153-
tipc_socket_stop();
154-
out_socket:
155156
unregister_pernet_subsys(&tipc_net_ops);
156157
out_pernet:
157158
tipc_unregister_sysctl();
@@ -167,7 +168,6 @@ static int __init tipc_init(void)
167168
static void __exit tipc_exit(void)
168169
{
169170
tipc_bearer_cleanup();
170-
tipc_socket_stop();
171171
unregister_pernet_subsys(&tipc_net_ops);
172172
tipc_netlink_stop();
173173
tipc_netlink_compat_stop();

0 commit comments

Comments
 (0)