All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] crypto: qat: Fix a double free in adf_create_ring
@ 2021-04-02 17:13 Lv Yunlong
  2021-04-09  7:55 ` Herbert Xu
  0 siblings, 1 reply; 2+ messages in thread
From: Lv Yunlong @ 2021-04-02 17:13 UTC (permalink / raw)
  To: giovanni.cabiddu, herbert, davem, andriy.shevchenko,
	wojciech.ziemba, fiona.trahe
  Cc: qat-linux, linux-crypto, linux-kernel, Lv Yunlong

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>
---
 drivers/crypto/qat/qat_common/adf_transport.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/crypto/qat/qat_common/adf_transport.c b/drivers/crypto/qat/qat_common/adf_transport.c
index 888c1e047295..8ba28409fb74 100644
--- a/drivers/crypto/qat/qat_common/adf_transport.c
+++ b/drivers/crypto/qat/qat_common/adf_transport.c
@@ -172,6 +172,7 @@ static int adf_init_ring(struct adf_etr_ring_data *ring)
 		dev_err(&GET_DEV(accel_dev), "Ring address not aligned\n");
 		dma_free_coherent(&GET_DEV(accel_dev), ring_size_bytes,
 				  ring->base_addr, ring->dma_addr);
+		ring->base_addr = NULL;
 		return -EFAULT;
 	}
 
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] crypto: qat: Fix a double free in adf_create_ring
  2021-04-02 17:13 [PATCH] crypto: qat: Fix a double free in adf_create_ring Lv Yunlong
@ 2021-04-09  7:55 ` Herbert Xu
  0 siblings, 0 replies; 2+ messages in thread
From: Herbert Xu @ 2021-04-09  7:55 UTC (permalink / raw)
  To: Lv Yunlong
  Cc: giovanni.cabiddu, davem, andriy.shevchenko, wojciech.ziemba,
	fiona.trahe, qat-linux, linux-crypto, linux-kernel

On Fri, Apr 02, 2021 at 10:13:48AM -0700, Lv Yunlong wrote:
> 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>
> ---
>  drivers/crypto/qat/qat_common/adf_transport.c | 1 +
>  1 file changed, 1 insertion(+)

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-04-09  7:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-02 17:13 [PATCH] crypto: qat: Fix a double free in adf_create_ring Lv Yunlong
2021-04-09  7:55 ` Herbert Xu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.