diff options
author | Ovidiu Panait <ovidiu.panait@windriver.com> | 2023-12-01 18:06:23 +0100 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2023-12-08 04:59:45 +0100 |
commit | ee6e6f0a7f5b39d50a5ef5fcc006f4f693db18a7 (patch) | |
tree | 8061606770bf09b07017f5ed1e78bafb0efe2008 /drivers/crypto/sahara.c | |
parent | crypto: sahara - fix processing requests with cryptlen < sg->length (diff) | |
download | linux-ee6e6f0a7f5b39d50a5ef5fcc006f4f693db18a7.tar.xz linux-ee6e6f0a7f5b39d50a5ef5fcc006f4f693db18a7.zip |
crypto: sahara - fix error handling in sahara_hw_descriptor_create()
Do not call dma_unmap_sg() for scatterlists that were not mapped
successfully.
Fixes: 5de8875281e1 ("crypto: sahara - Add driver for SAHARA2 accelerator.")
Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/crypto/sahara.c')
-rw-r--r-- | drivers/crypto/sahara.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/drivers/crypto/sahara.c b/drivers/crypto/sahara.c index cbb7153e4162..c4eb66d2e08d 100644 --- a/drivers/crypto/sahara.c +++ b/drivers/crypto/sahara.c @@ -483,13 +483,14 @@ static int sahara_hw_descriptor_create(struct sahara_dev *dev) DMA_TO_DEVICE); if (!ret) { dev_err(dev->device, "couldn't map in sg\n"); - goto unmap_in; + return -EINVAL; } + ret = dma_map_sg(dev->device, dev->out_sg, dev->nb_out_sg, DMA_FROM_DEVICE); if (!ret) { dev_err(dev->device, "couldn't map out sg\n"); - goto unmap_out; + goto unmap_in; } /* Create input links */ @@ -537,9 +538,6 @@ static int sahara_hw_descriptor_create(struct sahara_dev *dev) return 0; -unmap_out: - dma_unmap_sg(dev->device, dev->out_sg, dev->nb_out_sg, - DMA_FROM_DEVICE); unmap_in: dma_unmap_sg(dev->device, dev->in_sg, dev->nb_in_sg, DMA_TO_DEVICE); |