diff options
Diffstat (limited to 'net/xfrm/xfrm_state.c')
-rw-r--r-- | net/xfrm/xfrm_state.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c index 48b4a06b3d1a..224b44e31a07 100644 --- a/net/xfrm/xfrm_state.c +++ b/net/xfrm/xfrm_state.c | |||
@@ -377,8 +377,10 @@ static void xfrm_state_gc_destroy(struct xfrm_state *x) | |||
377 | kfree(x->calg); | 377 | kfree(x->calg); |
378 | kfree(x->encap); | 378 | kfree(x->encap); |
379 | kfree(x->coaddr); | 379 | kfree(x->coaddr); |
380 | if (x->mode) | 380 | if (x->inner_mode) |
381 | xfrm_put_mode(x->mode); | 381 | xfrm_put_mode(x->inner_mode); |
382 | if (x->outer_mode) | ||
383 | xfrm_put_mode(x->outer_mode); | ||
382 | if (x->type) { | 384 | if (x->type) { |
383 | x->type->destructor(x); | 385 | x->type->destructor(x); |
384 | xfrm_put_type(x->type); | 386 | xfrm_put_type(x->type); |
@@ -1947,6 +1949,14 @@ int xfrm_init_state(struct xfrm_state *x) | |||
1947 | goto error; | 1949 | goto error; |
1948 | 1950 | ||
1949 | err = -EPROTONOSUPPORT; | 1951 | err = -EPROTONOSUPPORT; |
1952 | x->inner_mode = xfrm_get_mode(x->props.mode, x->sel.family); | ||
1953 | if (x->inner_mode == NULL) | ||
1954 | goto error; | ||
1955 | |||
1956 | if (!(x->inner_mode->flags & XFRM_MODE_FLAG_TUNNEL) && | ||
1957 | family != x->sel.family) | ||
1958 | goto error; | ||
1959 | |||
1950 | x->type = xfrm_get_type(x->id.proto, family); | 1960 | x->type = xfrm_get_type(x->id.proto, family); |
1951 | if (x->type == NULL) | 1961 | if (x->type == NULL) |
1952 | goto error; | 1962 | goto error; |
@@ -1955,8 +1965,8 @@ int xfrm_init_state(struct xfrm_state *x) | |||
1955 | if (err) | 1965 | if (err) |
1956 | goto error; | 1966 | goto error; |
1957 | 1967 | ||
1958 | x->mode = xfrm_get_mode(x->props.mode, family); | 1968 | x->outer_mode = xfrm_get_mode(x->props.mode, family); |
1959 | if (x->mode == NULL) | 1969 | if (x->outer_mode == NULL) |
1960 | goto error; | 1970 | goto error; |
1961 | 1971 | ||
1962 | x->km.state = XFRM_STATE_VALID; | 1972 | x->km.state = XFRM_STATE_VALID; |