Skip to content

Commit 2dad81a

Browse files
Florian Westphalummakynes
authored andcommitted
netfilter: ipv6: fix afinfo->route refcnt leak on error
Several callers (h323 conntrack, xt_addrtype) assume that the returned **dst only needs to be released if the function returns 0. This is true for the ipv4 implementation, but not for the ipv6 one. Instead of changing the users, change the ipv6 implementation to behave like the ipv4 version by only providing the dst_entry result in the success case. Signed-off-by: Florian Westphal <fw@strlen.de> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
1 parent e23ebf0 commit 2dad81a

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

‎net/ipv6/netfilter.c‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,16 @@ static int nf_ip6_route(struct net *net, struct dst_entry **dst,
100100
.pinet6 = (struct ipv6_pinfo *) &fake_pinfo,
101101
};
102102
const void *sk = strict ? &fake_sk : NULL;
103-
104-
*dst = ip6_route_output(net, sk, &fl->u.ip6);
105-
return (*dst)->error;
103+
struct dst_entry *result;
104+
int err;
105+
106+
result = ip6_route_output(net, sk, &fl->u.ip6);
107+
err = result->error;
108+
if (err)
109+
dst_release(result);
110+
else
111+
*dst = result;
112+
return err;
106113
}
107114

108115
__sum16 nf_ip6_checksum(struct sk_buff *skb, unsigned int hook,

0 commit comments

Comments
 (0)