]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.4/tipc-fix-modprobe-tipc-failed-after-switch-order-of-device-registration.patch
fixes for 4.19
[thirdparty/kernel/stable-queue.git] / queue-4.4 / tipc-fix-modprobe-tipc-failed-after-switch-order-of-device-registration.patch
1 From foo@baz Wed 22 May 2019 07:38:16 PM CEST
2 From: Junwei Hu <hujunwei4@huawei.com>
3 Date: Fri, 17 May 2019 19:27:34 +0800
4 Subject: tipc: fix modprobe tipc failed after switch order of device registration
5
6 From: Junwei Hu <hujunwei4@huawei.com>
7
8 [ Upstream commit 532b0f7ece4cb2ffd24dc723ddf55242d1188e5e ]
9
10 Error message printed:
11 modprobe: ERROR: could not insert 'tipc': Address family not
12 supported by protocol.
13 when modprobe tipc after the following patch: switch order of
14 device registration, commit 7e27e8d6130c
15 ("tipc: switch order of device registration to fix a crash")
16
17 Because sock_create_kern(net, AF_TIPC, ...) is called by
18 tipc_topsrv_create_listener() in the initialization process
19 of tipc_net_ops, tipc_socket_init() must be execute before that.
20
21 I move tipc_socket_init() into function tipc_init_net().
22
23 Fixes: 7e27e8d6130c
24 ("tipc: switch order of device registration to fix a crash")
25 Signed-off-by: Junwei Hu <hujunwei4@huawei.com>
26 Reported-by: Wang Wang <wangwang2@huawei.com>
27 Reviewed-by: Kang Zhou <zhoukang7@huawei.com>
28 Reviewed-by: Suanming Mou <mousuanming@huawei.com>
29 Signed-off-by: David S. Miller <davem@davemloft.net>
30 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
31 ---
32 net/tipc/core.c | 14 +++++++-------
33 1 file changed, 7 insertions(+), 7 deletions(-)
34
35 --- a/net/tipc/core.c
36 +++ b/net/tipc/core.c
37 @@ -61,6 +61,10 @@ static int __net_init tipc_init_net(stru
38 INIT_LIST_HEAD(&tn->node_list);
39 spin_lock_init(&tn->node_list_lock);
40
41 + err = tipc_socket_init();
42 + if (err)
43 + goto out_socket;
44 +
45 err = tipc_sk_rht_init(net);
46 if (err)
47 goto out_sk_rht;
48 @@ -87,6 +91,8 @@ out_subscr:
49 out_nametbl:
50 tipc_sk_rht_destroy(net);
51 out_sk_rht:
52 + tipc_socket_stop();
53 +out_socket:
54 return err;
55 }
56
57 @@ -97,6 +103,7 @@ static void __net_exit tipc_exit_net(str
58 tipc_bcast_stop(net);
59 tipc_nametbl_stop(net);
60 tipc_sk_rht_destroy(net);
61 + tipc_socket_stop();
62 }
63
64 static struct pernet_operations tipc_net_ops = {
65 @@ -134,10 +141,6 @@ static int __init tipc_init(void)
66 if (err)
67 goto out_pernet;
68
69 - err = tipc_socket_init();
70 - if (err)
71 - goto out_socket;
72 -
73 err = tipc_bearer_setup();
74 if (err)
75 goto out_bearer;
76 @@ -145,8 +148,6 @@ static int __init tipc_init(void)
77 pr_info("Started in single node mode\n");
78 return 0;
79 out_bearer:
80 - tipc_socket_stop();
81 -out_socket:
82 unregister_pernet_subsys(&tipc_net_ops);
83 out_pernet:
84 tipc_unregister_sysctl();
85 @@ -162,7 +163,6 @@ out_netlink:
86 static void __exit tipc_exit(void)
87 {
88 tipc_bearer_cleanup();
89 - tipc_socket_stop();
90 unregister_pernet_subsys(&tipc_net_ops);
91 tipc_netlink_stop();
92 tipc_netlink_compat_stop();