]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
tipc: fix modprobe tipc failed after switch order of device registration
authorJunwei Hu <hujunwei4@huawei.com>
Fri, 17 May 2019 11:27:34 +0000 (19:27 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 25 May 2019 16:21:55 +0000 (18:21 +0200)
[ Upstream commit 532b0f7ece4cb2ffd24dc723ddf55242d1188e5e ]

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/tipc/core.c

index dbfc1e8b2866ca2b49f0bcb8baa35d46186f790e..d7b0688c98ddd6889826059c79386f14849eac79 100644 (file)
@@ -66,6 +66,10 @@ static int __net_init tipc_init_net(struct net *net)
        INIT_LIST_HEAD(&tn->node_list);
        spin_lock_init(&tn->node_list_lock);
 
+       err = tipc_socket_init();
+       if (err)
+               goto out_socket;
+
        err = tipc_sk_rht_init(net);
        if (err)
                goto out_sk_rht;
@@ -92,6 +96,8 @@ out_subscr:
 out_nametbl:
        tipc_sk_rht_destroy(net);
 out_sk_rht:
+       tipc_socket_stop();
+out_socket:
        return err;
 }
 
@@ -102,6 +108,7 @@ static void __net_exit tipc_exit_net(struct net *net)
        tipc_bcast_stop(net);
        tipc_nametbl_stop(net);
        tipc_sk_rht_destroy(net);
+       tipc_socket_stop();
 }
 
 static struct pernet_operations tipc_net_ops = {
@@ -137,10 +144,6 @@ static int __init tipc_init(void)
        if (err)
                goto out_pernet;
 
-       err = tipc_socket_init();
-       if (err)
-               goto out_socket;
-
        err = tipc_bearer_setup();
        if (err)
                goto out_bearer;
@@ -148,8 +151,6 @@ static int __init tipc_init(void)
        pr_info("Started in single node mode\n");
        return 0;
 out_bearer:
-       tipc_socket_stop();
-out_socket:
        unregister_pernet_subsys(&tipc_net_ops);
 out_pernet:
        tipc_unregister_sysctl();
@@ -165,7 +166,6 @@ out_netlink:
 static void __exit tipc_exit(void)
 {
        tipc_bearer_cleanup();
-       tipc_socket_stop();
        unregister_pernet_subsys(&tipc_net_ops);
        tipc_netlink_stop();
        tipc_netlink_compat_stop();