Patchwork ipv4: avoid to double release dst in tcp_v4_connect

login
register
mail settings
Submitter roy.qing.li@gmail.com
Date Nov. 17, 2011, 8:33 a.m.
Message ID <1321518828-4288-1-git-send-email-roy.qing.li@gmail.com>
Download mbox | patch
Permalink /patch/126158/
State Rejected
Delegated to: David Miller
Headers show

Comments

roy.qing.li@gmail.com - Nov. 17, 2011, 8:33 a.m.
From: RongQing.Li <roy.qing.li@gmail.com> 

When tcp_connect failed in tcp_v4_connect, the dst will be
released in error handler of tcp_v4_connect, but dst has been
set to sk->sk_dst_cache which will be released again when
destroy this sk.

Signed-off-by: RongQing.Li <roy.qing.li@gmail.com>
---
 net/ipv4/tcp_ipv4.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
David Miller - Nov. 17, 2011, 9:56 p.m.
From: roy.qing.li@gmail.com
Date: Thu, 17 Nov 2011 16:33:48 +0800

> From: RongQing.Li <roy.qing.li@gmail.com> 
> 
> When tcp_connect failed in tcp_v4_connect, the dst will be
> released in error handler of tcp_v4_connect, but dst has been
> set to sk->sk_dst_cache which will be released again when
> destroy this sk.
> 
> Signed-off-by: RongQing.Li <roy.qing.li@gmail.com>

We set 'rt' to NULL at these statements specifically to handle this
situation, ip_rt_put(NULL) will do nothing.

I don't think this change is necessary.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
roy.qing.li@gmail.com - Nov. 17, 2011, 11:54 p.m.
2011/11/18 David Miller <davem@davemloft.net>:
> We set 'rt' to NULL at these statements specifically to handle this
> situation, ip_rt_put(NULL) will do nothing.
>
> I don't think this change is necessary.
>

Yes, I am wrong, thank you.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index a744315..adc2992 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -263,8 +263,10 @@  int tcp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
 
 	err = tcp_connect(sk);
 	rt = NULL;
-	if (err)
+	if (err) {
+		sk->sk_dst_cache = NULL;
 		goto failure;
+	}
 
 	return 0;