mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 02:30:34 +02:00 
			
		
		
		
	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, commit7e27e8d613("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:7e27e8d613("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>
This commit is contained in:
		
							parent
							
								
									38a04b83ab
								
							
						
					
					
						commit
						532b0f7ece
					
				
					 1 changed files with 7 additions and 7 deletions
				
			
		| 
						 | 
					@ -68,6 +68,10 @@ static int __net_init tipc_init_net(struct net *net)
 | 
				
			||||||
	INIT_LIST_HEAD(&tn->node_list);
 | 
						INIT_LIST_HEAD(&tn->node_list);
 | 
				
			||||||
	spin_lock_init(&tn->node_list_lock);
 | 
						spin_lock_init(&tn->node_list_lock);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						err = tipc_socket_init();
 | 
				
			||||||
 | 
						if (err)
 | 
				
			||||||
 | 
							goto out_socket;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	err = tipc_sk_rht_init(net);
 | 
						err = tipc_sk_rht_init(net);
 | 
				
			||||||
	if (err)
 | 
						if (err)
 | 
				
			||||||
		goto out_sk_rht;
 | 
							goto out_sk_rht;
 | 
				
			||||||
| 
						 | 
					@ -94,6 +98,8 @@ static int __net_init tipc_init_net(struct net *net)
 | 
				
			||||||
out_nametbl:
 | 
					out_nametbl:
 | 
				
			||||||
	tipc_sk_rht_destroy(net);
 | 
						tipc_sk_rht_destroy(net);
 | 
				
			||||||
out_sk_rht:
 | 
					out_sk_rht:
 | 
				
			||||||
 | 
						tipc_socket_stop();
 | 
				
			||||||
 | 
					out_socket:
 | 
				
			||||||
	return err;
 | 
						return err;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -104,6 +110,7 @@ static void __net_exit tipc_exit_net(struct net *net)
 | 
				
			||||||
	tipc_bcast_stop(net);
 | 
						tipc_bcast_stop(net);
 | 
				
			||||||
	tipc_nametbl_stop(net);
 | 
						tipc_nametbl_stop(net);
 | 
				
			||||||
	tipc_sk_rht_destroy(net);
 | 
						tipc_sk_rht_destroy(net);
 | 
				
			||||||
 | 
						tipc_socket_stop();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static struct pernet_operations tipc_net_ops = {
 | 
					static struct pernet_operations tipc_net_ops = {
 | 
				
			||||||
| 
						 | 
					@ -139,10 +146,6 @@ static int __init tipc_init(void)
 | 
				
			||||||
	if (err)
 | 
						if (err)
 | 
				
			||||||
		goto out_pernet;
 | 
							goto out_pernet;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	err = tipc_socket_init();
 | 
					 | 
				
			||||||
	if (err)
 | 
					 | 
				
			||||||
		goto out_socket;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	err = tipc_bearer_setup();
 | 
						err = tipc_bearer_setup();
 | 
				
			||||||
	if (err)
 | 
						if (err)
 | 
				
			||||||
		goto out_bearer;
 | 
							goto out_bearer;
 | 
				
			||||||
| 
						 | 
					@ -150,8 +153,6 @@ static int __init tipc_init(void)
 | 
				
			||||||
	pr_info("Started in single node mode\n");
 | 
						pr_info("Started in single node mode\n");
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
out_bearer:
 | 
					out_bearer:
 | 
				
			||||||
	tipc_socket_stop();
 | 
					 | 
				
			||||||
out_socket:
 | 
					 | 
				
			||||||
	unregister_pernet_subsys(&tipc_net_ops);
 | 
						unregister_pernet_subsys(&tipc_net_ops);
 | 
				
			||||||
out_pernet:
 | 
					out_pernet:
 | 
				
			||||||
	tipc_unregister_sysctl();
 | 
						tipc_unregister_sysctl();
 | 
				
			||||||
| 
						 | 
					@ -167,7 +168,6 @@ static int __init tipc_init(void)
 | 
				
			||||||
static void __exit tipc_exit(void)
 | 
					static void __exit tipc_exit(void)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	tipc_bearer_cleanup();
 | 
						tipc_bearer_cleanup();
 | 
				
			||||||
	tipc_socket_stop();
 | 
					 | 
				
			||||||
	unregister_pernet_subsys(&tipc_net_ops);
 | 
						unregister_pernet_subsys(&tipc_net_ops);
 | 
				
			||||||
	tipc_netlink_stop();
 | 
						tipc_netlink_stop();
 | 
				
			||||||
	tipc_netlink_compat_stop();
 | 
						tipc_netlink_compat_stop();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue