Skip to content

Commit

Permalink
netfilter: ipv6: fix afinfo->route refcnt leak on error
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Pablo Neira Ayuso <[email protected]>
  • Loading branch information
Florian Westphal authored and ummakynes committed Nov 1, 2011
1 parent e23ebf0 commit 2dad81a
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions net/ipv6/netfilter.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 2dad81a

Please sign in to comment.