diff options
Diffstat (limited to 'net')
-rw-r--r-- | net/core/net_namespace.c | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c index 662e6ea1ce..4e52921ade 100644 --- a/net/core/net_namespace.c +++ b/net/core/net_namespace.c | |||
@@ -187,29 +187,28 @@ static int register_pernet_operations(struct list_head *list, | |||
187 | struct net *net, *undo_net; | 187 | struct net *net, *undo_net; |
188 | int error; | 188 | int error; |
189 | 189 | ||
190 | error = 0; | ||
191 | list_add_tail(&ops->list, list); | 190 | list_add_tail(&ops->list, list); |
192 | for_each_net(net) { | 191 | if (ops->init) { |
193 | if (ops->init) { | 192 | for_each_net(net) { |
194 | error = ops->init(net); | 193 | error = ops->init(net); |
195 | if (error) | 194 | if (error) |
196 | goto out_undo; | 195 | goto out_undo; |
197 | } | 196 | } |
198 | } | 197 | } |
199 | out: | 198 | return 0; |
200 | return error; | ||
201 | 199 | ||
202 | out_undo: | 200 | out_undo: |
203 | /* If I have an error cleanup all namespaces I initialized */ | 201 | /* If I have an error cleanup all namespaces I initialized */ |
204 | list_del(&ops->list); | 202 | list_del(&ops->list); |
205 | for_each_net(undo_net) { | 203 | if (ops->exit) { |
206 | if (undo_net == net) | 204 | for_each_net(undo_net) { |
207 | goto undone; | 205 | if (undo_net == net) |
208 | if (ops->exit) | 206 | goto undone; |
209 | ops->exit(undo_net); | 207 | ops->exit(undo_net); |
208 | } | ||
210 | } | 209 | } |
211 | undone: | 210 | undone: |
212 | goto out; | 211 | return error; |
213 | } | 212 | } |
214 | 213 | ||
215 | static void unregister_pernet_operations(struct pernet_operations *ops) | 214 | static void unregister_pernet_operations(struct pernet_operations *ops) |
@@ -217,8 +216,8 @@ static void unregister_pernet_operations(struct pernet_operations *ops) | |||
217 | struct net *net; | 216 | struct net *net; |
218 | 217 | ||
219 | list_del(&ops->list); | 218 | list_del(&ops->list); |
220 | for_each_net(net) | 219 | if (ops->exit) |
221 | if (ops->exit) | 220 | for_each_net(net) |
222 | ops->exit(net); | 221 | ops->exit(net); |
223 | } | 222 | } |
224 | 223 | ||