Skip to contentSkip to conversation

netfilter: ipv6: fix afinfo->route refcnt leak on error

PATCH Superseded Florian Westphal 1 participant 1 message Sep 6, 2011

Subsystems (2)
lore
Share & tools
lore

Florian Westphal

author maintainer
#0 lore raw

PATCH 1/1 netfilter: ipv6: fix afinfo->route refcnt leak on error

Several callers (conntrack_h323, xt_addrtype) assume that the returned **dst only needs to be released if the function returns 0.

Instead of changing the callers, fix the ipv6 implementation to behave like the ipv4 version by only providing *dst result in the success case.

---
 net/ipv6/netfilter.c |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)
net/ipv6/netfilter.c +10 -3
index 30fcee4..8992cf6 100644
@@ -100,9 +100,16 @@ static int nf_ip6_route(struct net *net, struct dst_entry **dst,
 		.pinet6 = (struct ipv6_pinfo *) &fake_pinfo,
 	};
 	const void *sk = strict ? &fake_sk : NULL;
-
-	*dst = ip6_route_output(net, sk, &fl->u.ip6);
-	return (*dst)->error;
+	struct dst_entry *result;
+	int err;
+
+	result = ip6_route_output(net, sk, &fl->u.ip6);
+	err = result->error;
+	if (err)
+		dst_release(result);
+	else
+		*dst = result;
+	return err;
 }
 
 __sum16 nf_ip6_checksum(struct sk_buff *skb, unsigned int hook,
Signature · 1 line
1.7.3.4