Re: [net] xfrm_user: use xfrm_state_put to free xfrm_state_alloc return value

From: Herbert Xu
Date: Wed Nov 21 2018 - 03:00:54 EST


On Wed, Nov 21, 2018 at 02:57:48PM +0800, Pan Bian wrote:
> From: Pan Bian <bianpan2013@xxxxxxx>
>
> The memory chunk allocated by xfrm_state_alloc() should be released with
> xfrm_state_put(), not kfree.
>
> Signed-off-by: Pan Bian <bianpan2013@xxxxxxx>

This bug was introduced by

commit 565f0fa902b64020d5d147ff1708567e9e0b6e49
Author: Mathias Krause <minipli@xxxxxxxxxxxxxx>
Date: Thu May 3 10:55:07 2018 +0200

While using xfrm_state_put may work it's certainly not the designed
to do this. We should instead export a function that calls
kmem_cache_free on xfrm_state directly and use that here.

Thanks,
--
Email: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt