Subject: [PATCH 2.6.9]: Fix inet6_dev reference leak in ndisc_dst_alloc error path

From: Patrick McHardy <[email-masked]>
Date: Wed, 20 Oct 2004 00:02:31 +0200

ndisc_dst_alloc leaks a inet6_dev reference when ip6_dst_alloc
returns NULL. The bug was introduced somewhere between 2.6.8
and 2.6.9.

Regards
Patrick

# This is a BitKeeper generated diff -Nru style patch.
#
# ChangeSet
#   2004/10/19 23:13:24+02:00 [email-masked] 
#   [IPV6]: Fix inet6_dev reference leak in ndisc_dst_alloc error path
#   
#   Signed-off-by: Patrick McHardy <[email-masked]>
# 
# net/ipv6/route.c
#   2004/10/19 23:12:48+02:00 [email-masked] +3 -1
#   [IPV6]: Fix inet6_dev reference leak in ndisc_dst_alloc error path
#   
#   Signed-off-by: Patrick McHardy <[email-masked]>
# 
diff -Nru a/net/ipv6/route.c b/net/ipv6/route.c
--- a/net/ipv6/route.c	2004-10-19 23:51:11 +02:00
+++ b/net/ipv6/route.c	2004-10-19 23:51:11 +02:00
@@ -647,8 +647,10 @@
 		return NULL;
 
 	rt = ip6_dst_alloc();
-	if (unlikely(rt == NULL))
+	if (unlikely(rt == NULL)) {
+		in6_dev_put(idev);
 		goto out;
+	}
 
 	dev_hold(dev);
 	if (neigh)