aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc/core.c
diff options
context:
space:
mode:
authorYing Xue <ying.xue@windriver.com>2014-02-19 22:32:49 -0500
committerDavid S. Miller <davem@davemloft.net>2014-02-22 00:00:15 -0500
commit9fe7ed474956944443eec57c5f75be12e10da84e (patch)
treedb26e8900f9967600d7d58633e3ef95071e8f991 /net/tipc/core.c
parent7cce3b75682ff898c935c17d186983cbf3ed393e (diff)
tipc: remove all enabled flags from all tipc components
When tipc module is inserted, many tipc components are initialized one by one. During the initialization period, if one of them is failed, tipc_core_stop() will be called to stop all components whatever corresponding components are created or not. To avoid to release uncreated ones, relevant components have to add necessary enabled flags indicating whether they are created or not. But in the initialization stage, if one component is unsuccessfully created, we will just destroy successfully created components before the failed component instead of all components. All enabled flags defined in components, in turn, become redundant. Additionally it's also unnecessary to identify whether table.types is NULL in tipc_nametbl_stop() because name stable has been definitely created successfully when tipc_nametbl_stop() is called. Cc: Jon Maloy <jon.maloy@ericsson.com> Cc: Erik Hugne <erik.hugne@ericsson.com> Signed-off-by: Ying Xue <ying.xue@windriver.com> Reviewed-by: Paul Gortmaker <paul.gortmaker@windriver.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tipc/core.c')
-rw-r--r--net/tipc/core.c71
1 files changed, 50 insertions, 21 deletions
diff --git a/net/tipc/core.c b/net/tipc/core.c
index f9e88d8b04ca..cfd9cc150110 100644
--- a/net/tipc/core.c
+++ b/net/tipc/core.c
@@ -122,30 +122,59 @@ static void tipc_core_stop(void)
122 */ 122 */
123static int tipc_core_start(void) 123static int tipc_core_start(void)
124{ 124{
125 int res; 125 int err;
126 126
127 get_random_bytes(&tipc_random, sizeof(tipc_random)); 127 get_random_bytes(&tipc_random, sizeof(tipc_random));
128 128
129 res = tipc_handler_start(); 129 err = tipc_handler_start();
130 if (!res) 130 if (err)
131 res = tipc_ref_table_init(tipc_max_ports, tipc_random); 131 goto out_handler;
132 if (!res) 132
133 res = tipc_nametbl_init(); 133 err = tipc_ref_table_init(tipc_max_ports, tipc_random);
134 if (!res) 134 if (err)
135 res = tipc_netlink_start(); 135 goto out_reftbl;
136 if (!res) 136
137 res = tipc_socket_init(); 137 err = tipc_nametbl_init();
138 if (!res) 138 if (err)
139 res = tipc_register_sysctl(); 139 goto out_nametbl;
140 if (!res) 140
141 res = tipc_subscr_start(); 141 err = tipc_netlink_start();
142 if (!res) 142 if (err)
143 res = tipc_cfg_init(); 143 goto out_netlink;
144 if (res) { 144
145 tipc_handler_stop(); 145 err = tipc_socket_init();
146 tipc_core_stop(); 146 if (err)
147 } 147 goto out_socket;
148 return res; 148
149 err = tipc_register_sysctl();
150 if (err)
151 goto out_sysctl;
152
153 err = tipc_subscr_start();
154 if (err)
155 goto out_subscr;
156
157 err = tipc_cfg_init();
158 if (err)
159 goto out_cfg;
160
161 return 0;
162out_cfg:
163 tipc_subscr_stop();
164out_subscr:
165 tipc_unregister_sysctl();
166out_sysctl:
167 tipc_socket_stop();
168out_socket:
169 tipc_netlink_stop();
170out_netlink:
171 tipc_nametbl_stop();
172out_nametbl:
173 tipc_ref_table_stop();
174out_reftbl:
175 tipc_handler_stop();
176out_handler:
177 return err;
149} 178}
150 179
151static int __init tipc_init(void) 180static int __init tipc_init(void)