dccp: remove unnecessary codes in ipv6.c
authorRongQing.Li <roy.qing.li@gmail.com>
Sun, 1 Jul 2012 17:19:00 +0000 (17:19 +0000)
committerBen Hutchings <ben@decadent.org.uk>
Wed, 30 Dec 2015 02:26:02 +0000 (02:26 +0000)
commit 0979e465c5ab205b63a1c1820fe833f396a120f0 upstream.

opt always equals np->opts, so it is meaningless to define opt, and
check if opt does not equal np->opts and then try to free opt.

Signed-off-by: RongQing.Li <roy.qing.li@gmail.com>
Acked-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
[bwh: Backported to 3.2: adjust context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
net/dccp/ipv6.c

index 592b78c..2b18c35 100644 (file)
@@ -236,7 +236,6 @@ static int dccp_v6_send_response(struct sock *sk, struct request_sock *req,
        struct inet6_request_sock *ireq6 = inet6_rsk(req);
        struct ipv6_pinfo *np = inet6_sk(sk);
        struct sk_buff *skb;
        struct inet6_request_sock *ireq6 = inet6_rsk(req);
        struct ipv6_pinfo *np = inet6_sk(sk);
        struct sk_buff *skb;
-       struct ipv6_txoptions *opt = NULL;
        struct in6_addr *final_p, final;
        struct flowi6 fl6;
        int err = -1;
        struct in6_addr *final_p, final;
        struct flowi6 fl6;
        int err = -1;
@@ -252,9 +251,8 @@ static int dccp_v6_send_response(struct sock *sk, struct request_sock *req,
        fl6.fl6_sport = inet_rsk(req)->loc_port;
        security_req_classify_flow(req, flowi6_to_flowi(&fl6));
 
        fl6.fl6_sport = inet_rsk(req)->loc_port;
        security_req_classify_flow(req, flowi6_to_flowi(&fl6));
 
-       opt = np->opt;
 
 
-       final_p = fl6_update_dst(&fl6, opt, &final);
+       final_p = fl6_update_dst(&fl6, np->opt, &final);
 
        dst = ip6_dst_lookup_flow(sk, &fl6, final_p, false);
        if (IS_ERR(dst)) {
 
        dst = ip6_dst_lookup_flow(sk, &fl6, final_p, false);
        if (IS_ERR(dst)) {
@@ -271,13 +269,11 @@ static int dccp_v6_send_response(struct sock *sk, struct request_sock *req,
                                                         &ireq6->loc_addr,
                                                         &ireq6->rmt_addr);
                ipv6_addr_copy(&fl6.daddr, &ireq6->rmt_addr);
                                                         &ireq6->loc_addr,
                                                         &ireq6->rmt_addr);
                ipv6_addr_copy(&fl6.daddr, &ireq6->rmt_addr);
-               err = ip6_xmit(sk, skb, &fl6, opt, np->tclass);
+               err = ip6_xmit(sk, skb, &fl6, np->opt, np->tclass);
                err = net_xmit_eval(err);
        }
 
 done:
                err = net_xmit_eval(err);
        }
 
 done:
-       if (opt != NULL && opt != np->opt)
-               sock_kfree_s(sk, opt, opt->tot_len);
        dst_release(dst);
        return err;
 }
        dst_release(dst);
        return err;
 }
@@ -470,7 +466,6 @@ static struct sock *dccp_v6_request_recv_sock(struct sock *sk,
        struct inet_sock *newinet;
        struct dccp6_sock *newdp6;
        struct sock *newsk;
        struct inet_sock *newinet;
        struct dccp6_sock *newdp6;
        struct sock *newsk;
-       struct ipv6_txoptions *opt;
 
        if (skb->protocol == htons(ETH_P_IP)) {
                /*
 
        if (skb->protocol == htons(ETH_P_IP)) {
                /*
@@ -515,7 +510,6 @@ static struct sock *dccp_v6_request_recv_sock(struct sock *sk,
                return newsk;
        }
 
                return newsk;
        }
 
-       opt = np->opt;
 
        if (sk_acceptq_is_full(sk))
                goto out_overflow;
 
        if (sk_acceptq_is_full(sk))
                goto out_overflow;
@@ -527,7 +521,7 @@ static struct sock *dccp_v6_request_recv_sock(struct sock *sk,
                memset(&fl6, 0, sizeof(fl6));
                fl6.flowi6_proto = IPPROTO_DCCP;
                ipv6_addr_copy(&fl6.daddr, &ireq6->rmt_addr);
                memset(&fl6, 0, sizeof(fl6));
                fl6.flowi6_proto = IPPROTO_DCCP;
                ipv6_addr_copy(&fl6.daddr, &ireq6->rmt_addr);
-               final_p = fl6_update_dst(&fl6, opt, &final);
+               final_p = fl6_update_dst(&fl6, np->opt, &final);
                ipv6_addr_copy(&fl6.saddr, &ireq6->loc_addr);
                fl6.flowi6_oif = sk->sk_bound_dev_if;
                fl6.fl6_dport = inet_rsk(req)->rmt_port;
                ipv6_addr_copy(&fl6.saddr, &ireq6->loc_addr);
                fl6.flowi6_oif = sk->sk_bound_dev_if;
                fl6.fl6_dport = inet_rsk(req)->rmt_port;
@@ -592,11 +586,8 @@ static struct sock *dccp_v6_request_recv_sock(struct sock *sk,
         * Yes, keeping reference count would be much more clever, but we make
         * one more one thing there: reattach optmem to newsk.
         */
         * Yes, keeping reference count would be much more clever, but we make
         * one more one thing there: reattach optmem to newsk.
         */
-       if (opt != NULL) {
-               newnp->opt = ipv6_dup_options(newsk, opt);
-               if (opt != np->opt)
-                       sock_kfree_s(sk, opt, opt->tot_len);
-       }
+       if (np->opt != NULL)
+               newnp->opt = ipv6_dup_options(newsk, np->opt);
 
        inet_csk(newsk)->icsk_ext_hdr_len = 0;
        if (newnp->opt != NULL)
 
        inet_csk(newsk)->icsk_ext_hdr_len = 0;
        if (newnp->opt != NULL)
@@ -623,8 +614,6 @@ out_nonewsk:
        dst_release(dst);
 out:
        NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_LISTENDROPS);
        dst_release(dst);
 out:
        NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_LISTENDROPS);
-       if (opt != NULL && opt != np->opt)
-               sock_kfree_s(sk, opt, opt->tot_len);
        return NULL;
 }
 
        return NULL;
 }