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
15521552 int (*func)(struct xfrm_state *, int, void*), void *);
15531553 void xfrm_state_walk_done(struct xfrm_state_walk *walk, struct net *net);
15541554 struct xfrm_state *xfrm_state_alloc(struct net *net);
1555+void xfrm_state_free(struct xfrm_state *x);
15551556 struct xfrm_state *xfrm_state_find(const xfrm_address_t *daddr,
15561557 const xfrm_address_t *saddr,
15571558 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
426426 module_put(mode->owner);
427427 }
428428
429+void xfrm_state_free(struct xfrm_state *x)
430+{
431+ kmem_cache_free(xfrm_state_cache, x);
432+}
433+EXPORT_SYMBOL(xfrm_state_free);
434+
429435 static void xfrm_state_gc_destroy(struct xfrm_state *x)
430436 {
431437 tasklet_hrtimer_cancel(&x->mtimer);
@@ -452,7 +458,7 @@ static void xfrm_state_gc_destroy(struct xfrm_state *x) · 20 unmodified lines
452458 }
453459 xfrm_dev_state_free(x);
454460 security_xfrm_state_free(x);
455− kmem_cache_free(xfrm_state_cache, x);
461+ xfrm_state_free(x);
456462 }
457463
458464 static 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
22882288
22892289 }
22902290
2291− kfree(x);
2291+ xfrm_state_free(x);
22922292 kfree(xp);
22932293
22942294 return 0;
22952295
22962296 free_state:
2297− kfree(x);
2297+ xfrm_state_free(x);
22982298 nomem:
22992299 return err;
23002300 }