Skip to contentSkip to conversation

ipv4: avoid to double release dst in tcp_v4_connect

PATCH In review [email protected] 2 participants 3 messages Nov 17, 2011

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ipv4: avoid to double release dst in tcp_v4_connect

From: RongQing.Li <[email protected]>

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.

---
 net/ipv4/tcp_ipv4.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
net/ipv4/tcp_ipv4.c +3 -1
index a744315..adc2992 100644
@@ -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;
 
Signature · 1 line
1.7.1
maintainer
#1 lore raw

From: [email protected]
Date: Thu, 17 Nov 2011 16:33:48 +0800

Quoted 8 lines

From: RongQing.Li <[email protected]>

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.

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.

#2 lore raw

2011/11/18 David Miller <[email protected]>:

Quoted 5 lines

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.