Skip to content

Commit

Permalink
ipcomp: Avoid duplicate calls to ipcomp_destroy
Browse files Browse the repository at this point in the history
When ipcomp_tunnel_attach fails we will call ipcomp_destroy twice.
This may lead to double-frees on certain structures.

As there is no reason to explicitly call ipcomp_destroy, this patch
removes it from ipcomp*.c and lets the standard xfrm_state destruction
take place.

This is based on the discovery and patch by Alexey Dobriyan.

Tested-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Herbert Xu authored and David S. Miller committed Feb 16, 2010
1 parent 1cab819 commit 10e7454
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
6 changes: 1 addition & 5 deletions net/ipv4/ipcomp.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,12 @@ static int ipcomp4_init_state(struct xfrm_state *x)
if (x->props.mode == XFRM_MODE_TUNNEL) {
err = ipcomp_tunnel_attach(x);
if (err)
goto error_tunnel;
goto out;
}

err = 0;
out:
return err;

error_tunnel:
ipcomp_destroy(x);
goto out;
}

static const struct xfrm_type ipcomp_type = {
Expand Down
6 changes: 1 addition & 5 deletions net/ipv6/ipcomp6.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,16 +154,12 @@ static int ipcomp6_init_state(struct xfrm_state *x)
if (x->props.mode == XFRM_MODE_TUNNEL) {
err = ipcomp6_tunnel_attach(x);
if (err)
goto error_tunnel;
goto out;
}

err = 0;
out:
return err;
error_tunnel:
ipcomp_destroy(x);

goto out;
}

static const struct xfrm_type ipcomp6_type =
Expand Down

0 comments on commit 10e7454

Please sign in to comment.