crypto: qat - Fix a double free in adf_create_ring
authorLv Yunlong <lyl2019@mail.ustc.edu.cn>
Fri, 2 Apr 2021 17:13:48 +0000 (10:13 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 22 May 2021 08:57:29 +0000 (10:57 +0200)
commitd39adccb435846c4b01abb64c40b979c9aee4021
treec0531cbb579ad0a2121a2303387d051465d78bc7
parentd73b83efe2f36dc98cd85e06f6e5c0afb7a9b61f
crypto: qat - Fix a double free in adf_create_ring

[ Upstream commit f7cae626cabb3350b23722b78fe34dd7a615ca04 ]

In adf_create_ring, if the callee adf_init_ring() failed, the callee will
free the ring->base_addr by dma_free_coherent() and return -EFAULT. Then
adf_create_ring will goto err and the ring->base_addr will be freed again
in adf_cleanup_ring().

My patch sets ring->base_addr to NULL after the first freed to avoid the
double free.

Fixes: a672a9dc872ec ("crypto: qat - Intel(R) QAT transport code")
Signed-off-by: Lv Yunlong <lyl2019@mail.ustc.edu.cn>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/crypto/qat/qat_common/adf_transport.c