diff mbox series

crypto: octeontx2 - add missing check for dma_map_single

Message ID 20240408015914.101442-1-nichen@iscas.ac.cn (mailing list archive)
State Accepted
Delegated to: Herbert Xu
Headers show
Series crypto: octeontx2 - add missing check for dma_map_single | expand

Commit Message

Chen Ni April 8, 2024, 1:59 a.m. UTC
Add check for dma_map_single() and return error if it fails in order
to avoid invalid dma address.

Fixes: e92971117c2c ("crypto: octeontx2 - add ctx_val workaround")
Signed-off-by: Chen Ni <nichen@iscas.ac.cn>
---
 drivers/crypto/marvell/octeontx2/cn10k_cpt.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Bharat Bhushan April 9, 2024, 4:23 a.m. UTC | #1
> -----Original Message-----
> From: Chen Ni <nichen@iscas.ac.cn>
> Sent: Monday, April 8, 2024 7:29 AM
> To: bbrezillon@kernel.org; arno@natisbad.org; Srujana Challa
> <schalla@marvell.com>; herbert@gondor.apana.org.au;
> davem@davemloft.net
> Cc: linux-crypto@vger.kernel.org; linux-kernel@vger.kernel.org; Chen Ni
> <nichen@iscas.ac.cn>
> Subject: [EXTERNAL] [PATCH] crypto: octeontx2 - add missing check for
> dma_map_single
> 
> ----------------------------------------------------------------------
> Add check for dma_map_single() and return error if it fails in order to avoid
> invalid dma address.
> 
> Fixes: e92971117c2c ("crypto: octeontx2 - add ctx_val workaround")
> Signed-off-by: Chen Ni <nichen@iscas.ac.cn>
> ---
>  drivers/crypto/marvell/octeontx2/cn10k_cpt.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/crypto/marvell/octeontx2/cn10k_cpt.c
> b/drivers/crypto/marvell/octeontx2/cn10k_cpt.c
> index 79b4e74804f6..6bfc59e67747 100644
> --- a/drivers/crypto/marvell/octeontx2/cn10k_cpt.c
> +++ b/drivers/crypto/marvell/octeontx2/cn10k_cpt.c
> @@ -138,6 +138,10 @@ int cn10k_cpt_hw_ctx_init(struct pci_dev *pdev,
>  		return -ENOMEM;
>  	cptr_dma = dma_map_single(&pdev->dev, hctx,
> CN10K_CPT_HW_CTX_SIZE,
>  				  DMA_BIDIRECTIONAL);
> +	if (dma_mapping_error(&pdev->dev, cptr_dma)) {
> +		kfree(hctx);
> +		return -ENOMEM;
> +	}

Thanks for fixing,
Reviewed-by: Bharat Bhushan <bbhushan2@marvell.com>

> 
>  	cn10k_cpt_hw_ctx_set(hctx, 1);
>  	er_ctx->hw_ctx = hctx;
> --
> 2.25.1
>
Herbert Xu April 19, 2024, 10:57 a.m. UTC | #2
On Mon, Apr 08, 2024 at 01:59:14AM +0000, Chen Ni wrote:
> Add check for dma_map_single() and return error if it fails in order
> to avoid invalid dma address.
> 
> Fixes: e92971117c2c ("crypto: octeontx2 - add ctx_val workaround")
> Signed-off-by: Chen Ni <nichen@iscas.ac.cn>
> ---
>  drivers/crypto/marvell/octeontx2/cn10k_cpt.c | 4 ++++
>  1 file changed, 4 insertions(+)

Patch applied.  Thanks.
diff mbox series

Patch

diff --git a/drivers/crypto/marvell/octeontx2/cn10k_cpt.c b/drivers/crypto/marvell/octeontx2/cn10k_cpt.c
index 79b4e74804f6..6bfc59e67747 100644
--- a/drivers/crypto/marvell/octeontx2/cn10k_cpt.c
+++ b/drivers/crypto/marvell/octeontx2/cn10k_cpt.c
@@ -138,6 +138,10 @@  int cn10k_cpt_hw_ctx_init(struct pci_dev *pdev,
 		return -ENOMEM;
 	cptr_dma = dma_map_single(&pdev->dev, hctx, CN10K_CPT_HW_CTX_SIZE,
 				  DMA_BIDIRECTIONAL);
+	if (dma_mapping_error(&pdev->dev, cptr_dma)) {
+		kfree(hctx);
+		return -ENOMEM;
+	}
 
 	cn10k_cpt_hw_ctx_set(hctx, 1);
 	er_ctx->hw_ctx = hctx;