Skip to content

Commit 10e7454

Browse files
herbertxdavem330
authored andcommitted
ipcomp: Avoid duplicate calls to ipcomp_destroy
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 <[email protected]> Signed-off-by: Herbert Xu <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 1cab819 commit 10e7454

File tree

2 files changed

+2
-10
lines changed

2 files changed

+2
-10
lines changed

net/ipv4/ipcomp.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,16 +124,12 @@ static int ipcomp4_init_state(struct xfrm_state *x)
124124
if (x->props.mode == XFRM_MODE_TUNNEL) {
125125
err = ipcomp_tunnel_attach(x);
126126
if (err)
127-
goto error_tunnel;
127+
goto out;
128128
}
129129

130130
err = 0;
131131
out:
132132
return err;
133-
134-
error_tunnel:
135-
ipcomp_destroy(x);
136-
goto out;
137133
}
138134

139135
static const struct xfrm_type ipcomp_type = {

net/ipv6/ipcomp6.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,16 +154,12 @@ static int ipcomp6_init_state(struct xfrm_state *x)
154154
if (x->props.mode == XFRM_MODE_TUNNEL) {
155155
err = ipcomp6_tunnel_attach(x);
156156
if (err)
157-
goto error_tunnel;
157+
goto out;
158158
}
159159

160160
err = 0;
161161
out:
162162
return err;
163-
error_tunnel:
164-
ipcomp_destroy(x);
165-
166-
goto out;
167163
}
168164

169165
static const struct xfrm_type ipcomp6_type =

0 commit comments

Comments
 (0)