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.
Unified · Split
| @@ -1552,6 +1552,7 @@ int xfrm_state_walk(struct net *net, struct xfrm_state_walk *walk, · 1551 unmodified lines | ||
| 1552 | 1552 | int (*func)(struct xfrm_state *, int, void*), void *); |
| 1553 | 1553 | void xfrm_state_walk_done(struct xfrm_state_walk *walk, struct net *net); |
| 1554 | 1554 | struct xfrm_state *xfrm_state_alloc(struct net *net); |
| 1555 | +void xfrm_state_free(struct xfrm_state *x); | |
| 1555 | 1556 | struct xfrm_state *xfrm_state_find(const xfrm_address_t *daddr, |
| 1556 | 1557 | const xfrm_address_t *saddr, |
| 1557 | 1558 | const struct flowi *fl, |
| @@ -426,6 +426,12 @@ static void xfrm_put_mode(struct xfrm_mode *mode) · 425 unmodified lines | ||
| 426 | 426 | module_put(mode->owner); |
| 427 | 427 | } |
| 428 | 428 | |
| 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 | + | |
| 429 | 435 | static void xfrm_state_gc_destroy(struct xfrm_state *x) |
| 430 | 436 | { |
| 431 | 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 | 459 | xfrm_dev_state_free(x); |
| 454 | 460 | security_xfrm_state_free(x); |
| 455 | − kmem_cache_free(xfrm_state_cache, x); | |
| 461 | + xfrm_state_free(x); | |
| 456 | 462 | } |
| 457 | 463 | |
| 458 | 464 | static void xfrm_state_gc_task(struct work_struct *work) |
| @@ -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 | 2292 | kfree(xp); |
| 2293 | 2293 | |
| 2294 | 2294 | return 0; |
| 2295 | 2295 | |
| 2296 | 2296 | free_state: |
| 2297 | − kfree(x); | |
| 2297 | + xfrm_state_free(x); | |
| 2298 | 2298 | nomem: |
| 2299 | 2299 | return err; |
| 2300 | 2300 | } |