Skip to content

Commit 2dba8e1

Browse files
opanait-wrherbertx
authored andcommitted
crypto: sahara - fix wait_for_completion_timeout() error handling
The sg lists are not unmapped in case of timeout errors. Fix this. Fixes: 5a2bb93 ("crypto: sahara - add support for SHA1/256") Fixes: 5de8875 ("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>
1 parent efcb50f commit 2dba8e1

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

drivers/crypto/sahara.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -605,16 +605,17 @@ static int sahara_aes_process(struct skcipher_request *req)
605605

606606
timeout = wait_for_completion_timeout(&dev->dma_completion,
607607
msecs_to_jiffies(SAHARA_TIMEOUT_MS));
608-
if (!timeout) {
609-
dev_err(dev->device, "AES timeout\n");
610-
return -ETIMEDOUT;
611-
}
612608

613609
dma_unmap_sg(dev->device, dev->out_sg, dev->nb_out_sg,
614610
DMA_FROM_DEVICE);
615611
dma_unmap_sg(dev->device, dev->in_sg, dev->nb_in_sg,
616612
DMA_TO_DEVICE);
617613

614+
if (!timeout) {
615+
dev_err(dev->device, "AES timeout\n");
616+
return -ETIMEDOUT;
617+
}
618+
618619
if ((dev->flags & FLAGS_CBC) && req->iv)
619620
sahara_aes_cbc_update_iv(req);
620621

@@ -1005,15 +1006,16 @@ static int sahara_sha_process(struct ahash_request *req)
10051006

10061007
timeout = wait_for_completion_timeout(&dev->dma_completion,
10071008
msecs_to_jiffies(SAHARA_TIMEOUT_MS));
1008-
if (!timeout) {
1009-
dev_err(dev->device, "SHA timeout\n");
1010-
return -ETIMEDOUT;
1011-
}
10121009

10131010
if (rctx->sg_in_idx)
10141011
dma_unmap_sg(dev->device, dev->in_sg, dev->nb_in_sg,
10151012
DMA_TO_DEVICE);
10161013

1014+
if (!timeout) {
1015+
dev_err(dev->device, "SHA timeout\n");
1016+
return -ETIMEDOUT;
1017+
}
1018+
10171019
memcpy(rctx->context, dev->context_base, rctx->context_size);
10181020

10191021
if (req->result && rctx->last)

0 commit comments

Comments
 (0)