]> git.baikalelectronics.ru Git - kernel.git/commitdiff
ipv6: clean up cork setup/release
authorPavel Begunkov <asml.silence@gmail.com>
Thu, 27 Jan 2022 00:36:25 +0000 (00:36 +0000)
committerJakub Kicinski <kuba@kernel.org>
Fri, 28 Jan 2022 03:46:11 +0000 (19:46 -0800)
Clean up ip6_setup_cork() and ip6_cork_release() adding a local variable
for v6_cork->opt. It's a preparation patch for further changes.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Reviewed-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/ipv6/ip6_output.c

index 4acd577d5ec5dbd4e0c2d2cd32a92d6a0fc3485f..88349e49717a6a87330e454c79012e2602bea2d6 100644 (file)
@@ -1354,7 +1354,7 @@ static int ip6_setup_cork(struct sock *sk, struct inet_cork_full *cork,
 {
        struct ipv6_pinfo *np = inet6_sk(sk);
        unsigned int mtu;
-       struct ipv6_txoptions *opt = ipc6->opt;
+       struct ipv6_txoptions *nopt, *opt = ipc6->opt;
 
        /*
         * setup for corking
@@ -1363,32 +1363,28 @@ static int ip6_setup_cork(struct sock *sk, struct inet_cork_full *cork,
                if (WARN_ON(v6_cork->opt))
                        return -EINVAL;
 
-               v6_cork->opt = kzalloc(sizeof(*opt), sk->sk_allocation);
-               if (unlikely(!v6_cork->opt))
+               nopt = v6_cork->opt = kzalloc(sizeof(*opt), sk->sk_allocation);
+               if (unlikely(!nopt))
                        return -ENOBUFS;
 
-               v6_cork->opt->tot_len = sizeof(*opt);
-               v6_cork->opt->opt_flen = opt->opt_flen;
-               v6_cork->opt->opt_nflen = opt->opt_nflen;
+               nopt->tot_len = sizeof(*opt);
+               nopt->opt_flen = opt->opt_flen;
+               nopt->opt_nflen = opt->opt_nflen;
 
-               v6_cork->opt->dst0opt = ip6_opt_dup(opt->dst0opt,
-                                                   sk->sk_allocation);
-               if (opt->dst0opt && !v6_cork->opt->dst0opt)
+               nopt->dst0opt = ip6_opt_dup(opt->dst0opt, sk->sk_allocation);
+               if (opt->dst0opt && !nopt->dst0opt)
                        return -ENOBUFS;
 
-               v6_cork->opt->dst1opt = ip6_opt_dup(opt->dst1opt,
-                                                   sk->sk_allocation);
-               if (opt->dst1opt && !v6_cork->opt->dst1opt)
+               nopt->dst1opt = ip6_opt_dup(opt->dst1opt, sk->sk_allocation);
+               if (opt->dst1opt && !nopt->dst1opt)
                        return -ENOBUFS;
 
-               v6_cork->opt->hopopt = ip6_opt_dup(opt->hopopt,
-                                                  sk->sk_allocation);
-               if (opt->hopopt && !v6_cork->opt->hopopt)
+               nopt->hopopt = ip6_opt_dup(opt->hopopt, sk->sk_allocation);
+               if (opt->hopopt && !nopt->hopopt)
                        return -ENOBUFS;
 
-               v6_cork->opt->srcrt = ip6_rthdr_dup(opt->srcrt,
-                                                   sk->sk_allocation);
-               if (opt->srcrt && !v6_cork->opt->srcrt)
+               nopt->srcrt = ip6_rthdr_dup(opt->srcrt, sk->sk_allocation);
+               if (opt->srcrt && !nopt->srcrt)
                        return -ENOBUFS;
 
                /* need source address above miyazawa*/
@@ -1820,11 +1816,13 @@ static void ip6_cork_release(struct inet_cork_full *cork,
                             struct inet6_cork *v6_cork)
 {
        if (v6_cork->opt) {
-               kfree(v6_cork->opt->dst0opt);
-               kfree(v6_cork->opt->dst1opt);
-               kfree(v6_cork->opt->hopopt);
-               kfree(v6_cork->opt->srcrt);
-               kfree(v6_cork->opt);
+               struct ipv6_txoptions *opt = v6_cork->opt;
+
+               kfree(opt->dst0opt);
+               kfree(opt->dst1opt);
+               kfree(opt->hopopt);
+               kfree(opt->srcrt);
+               kfree(opt);
                v6_cork->opt = NULL;
        }