History

xfrm_user: fix freeing of xfrm states on acquire

Commit 565f0fa902b6 ("xfrm: use a dedicated slab cache for struct xfrm_state") moved xfrm state objects to use their own slab cache. However, it missed to adapt xfrm_user to use this new cache when freeing xfrm states. Fix this by introducing and make use of a new helper for freeing xfrm_state objects.

Mathias Krause committed 7 years ago

Commit 4a135e51 parent 0152eee3 files · +10 −3Browse files

Unified · Split

3 files
  1. include/net/xfrm.h +1 −0
  2. net/xfrm/xfrm_state.c +7 −1
  3. net/xfrm/xfrm_user.c +2 −2
include/net/xfrm.h+1−0
@@ -1552,6 +1552,7 @@ int xfrm_state_walk(struct net *net, struct xfrm_state_walk *walk, · 1551 unmodified lines
1552 int (*func)(struct xfrm_state *, int, void*), void *);1552 int (*func)(struct xfrm_state *, int, void*), void *);
1553void xfrm_state_walk_done(struct xfrm_state_walk *walk, struct net *net);1553void xfrm_state_walk_done(struct xfrm_state_walk *walk, struct net *net);
1554struct xfrm_state *xfrm_state_alloc(struct net *net);1554struct xfrm_state *xfrm_state_alloc(struct net *net);
1555void xfrm_state_free(struct xfrm_state *x);
1555struct xfrm_state *xfrm_state_find(const xfrm_address_t *daddr,1556struct xfrm_state *xfrm_state_find(const xfrm_address_t *daddr,
1556 const xfrm_address_t *saddr,1557 const xfrm_address_t *saddr,
1557 const struct flowi *fl,1558 const struct flowi *fl,
net/xfrm/xfrm_state.c+7−1
@@ -426,6 +426,12 @@ static void xfrm_put_mode(struct xfrm_mode *mode) · 425 unmodified lines
426 module_put(mode->owner);426 module_put(mode->owner);
427}427}
428 428
429void xfrm_state_free(struct xfrm_state *x)
430{
431 kmem_cache_free(xfrm_state_cache, x);
432}
433EXPORT_SYMBOL(xfrm_state_free);
434
429static void xfrm_state_gc_destroy(struct xfrm_state *x)435static void xfrm_state_gc_destroy(struct xfrm_state *x)
430{436{
431 tasklet_hrtimer_cancel(&x->mtimer);437 tasklet_hrtimer_cancel(&x->mtimer);
@@ -452,7 +458,7 @@ static void xfrm_state_gc_destroy(struct xfrm_state *x) · 20 unmodified lines
452 }458 }
453 xfrm_dev_state_free(x);459 xfrm_dev_state_free(x);
454 security_xfrm_state_free(x);460 security_xfrm_state_free(x);
455 kmem_cache_free(xfrm_state_cache, x);461 xfrm_state_free(x);
456}462}
457 463
458static void xfrm_state_gc_task(struct work_struct *work)464static void xfrm_state_gc_task(struct work_struct *work)
net/xfrm/xfrm_user.c+2−2
@@ -2288,13 +2288,13 @@ static int xfrm_add_acquire(struct sk_buff *skb, struct nlmsghdr *nlh, · 2287 unmodified lines
2288 2288
2289 }2289 }
2290 2290
2291 kfree(x);2291 xfrm_state_free(x);
2292 kfree(xp);2292 kfree(xp);
2293 2293
2294 return 0;2294 return 0;
2295 2295
2296free_state:2296free_state:
2297 kfree(x);2297 xfrm_state_free(x);
2298nomem:2298nomem:
2299 return err;2299 return err;
2300}2300}