Re: [PATCH] crypto: cesa: check for sram_dma NULL
From: Robin Murphy
Date: Mon Jul 13 2026 - 07:59:48 EST
On 13/07/2026 6:07 am, Rosen Penev wrote:
dma_map_resource() might fail. In such a case, don't call
dma_unmap_resource()
Hmm, AFAICS it's more that if *anything* in mv_cesa_get_sram() fails, we could end up calling dma_unmap_resource() via the cleanup path for subsequent engines which never had their mv_cesa_get_sram() call at all (and thus all of engine->pool, engine->sram and engine->sram_dma will be unset). While for one where dma_map_resource() itself did fail, engine->sram_dma will be non-NULL here (but still invalid to unmap). I think this needs a bit more work to differentiate between the successfully initialised state which needs cleanup, and the partially or fully-uninitialised states which don't.
Thanks,
Robin.
Fixes: 37d728f76c41 ("crypto: marvell/cesa - Fix DMA API misuse")
Signed-off-by: Rosen Penev <rosenp@xxxxxxxxx>
---
drivers/crypto/marvell/cesa/cesa.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/crypto/marvell/cesa/cesa.c b/drivers/crypto/marvell/cesa/cesa.c
index 57c9295be711..bcbb909c48d8 100644
--- a/drivers/crypto/marvell/cesa/cesa.c
+++ b/drivers/crypto/marvell/cesa/cesa.c
@@ -406,7 +406,7 @@ static void mv_cesa_put_sram(struct platform_device *pdev, int idx)
if (engine->pool)
gen_pool_free(engine->pool, (unsigned long)engine->sram_pool,
cesa->sram_size);
- else
+ else if (engine->sram_dma)
dma_unmap_resource(cesa->dev, engine->sram_dma,
cesa->sram_size, DMA_BIDIRECTIONAL, 0);
}