Commit 3232a1ef authored by Kefeng Wang's avatar Kefeng Wang Committed by David S. Miller

ipv6: icmp: use icmpv6_sk_exit()

Simply use icmpv6_sk_exit() when inet_ctl_sock_create() fail
in icmpv6_sk_init().
Signed-off-by: default avatarKefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent e9128c14
...@@ -953,10 +953,19 @@ void icmpv6_flow_init(struct sock *sk, struct flowi6 *fl6, ...@@ -953,10 +953,19 @@ void icmpv6_flow_init(struct sock *sk, struct flowi6 *fl6,
security_sk_classify_flow(sk, flowi6_to_flowi(fl6)); security_sk_classify_flow(sk, flowi6_to_flowi(fl6));
} }
static void __net_exit icmpv6_sk_exit(struct net *net)
{
int i;
for_each_possible_cpu(i)
inet_ctl_sock_destroy(net->ipv6.icmp_sk[i]);
kfree(net->ipv6.icmp_sk);
}
static int __net_init icmpv6_sk_init(struct net *net) static int __net_init icmpv6_sk_init(struct net *net)
{ {
struct sock *sk; struct sock *sk;
int err, i, j; int err, i;
net->ipv6.icmp_sk = net->ipv6.icmp_sk =
kcalloc(nr_cpu_ids, sizeof(struct sock *), GFP_KERNEL); kcalloc(nr_cpu_ids, sizeof(struct sock *), GFP_KERNEL);
...@@ -982,22 +991,10 @@ static int __net_init icmpv6_sk_init(struct net *net) ...@@ -982,22 +991,10 @@ static int __net_init icmpv6_sk_init(struct net *net)
return 0; return 0;
fail: fail:
for (j = 0; j < i; j++) icmpv6_sk_exit(net);
inet_ctl_sock_destroy(net->ipv6.icmp_sk[j]);
kfree(net->ipv6.icmp_sk);
return err; return err;
} }
static void __net_exit icmpv6_sk_exit(struct net *net)
{
int i;
for_each_possible_cpu(i) {
inet_ctl_sock_destroy(net->ipv6.icmp_sk[i]);
}
kfree(net->ipv6.icmp_sk);
}
static struct pernet_operations icmpv6_sk_ops = { static struct pernet_operations icmpv6_sk_ops = {
.init = icmpv6_sk_init, .init = icmpv6_sk_init,
.exit = icmpv6_sk_exit, .exit = icmpv6_sk_exit,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment