summaryrefslogtreecommitdiff
path: root/drivers/crypto/allwinner
diff options
context:
space:
mode:
authorCorentin Labbe <clabbe@baylibre.com>2022-05-02 20:19:15 +0000
committerHerbert Xu <herbert@gondor.apana.org.au>2022-05-13 17:24:18 +0800
commitc149e4763d28bb4c0e5daae8a59f2c74e889f407 (patch)
treed45f98587d09c1139d4f709af42100e14b8f4b95 /drivers/crypto/allwinner
parent359e893e8af456be2fefabe851716237df289cbf (diff)
crypto: sun8i-ss - handle zero sized sg
sun8i-ss does not handle well the possible zero sized sg. Fixes: d9b45418a917 ("crypto: sun8i-ss - support hash algorithms") Signed-off-by: Corentin Labbe <clabbe@baylibre.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/crypto/allwinner')
-rw-r--r--drivers/crypto/allwinner/sun8i-ss/sun8i-ss-hash.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-hash.c b/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-hash.c
index 1a71ed49d233..ca4f280af35d 100644
--- a/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-hash.c
+++ b/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-hash.c
@@ -380,13 +380,21 @@ int sun8i_ss_hash_run(struct crypto_engine *engine, void *breq)
}
len = areq->nbytes;
- for_each_sg(areq->src, sg, nr_sgs, i) {
+ sg = areq->src;
+ i = 0;
+ while (len > 0 && sg) {
+ if (sg_dma_len(sg) == 0) {
+ sg = sg_next(sg);
+ continue;
+ }
rctx->t_src[i].addr = sg_dma_address(sg);
todo = min(len, sg_dma_len(sg));
rctx->t_src[i].len = todo / 4;
len -= todo;
rctx->t_dst[i].addr = addr_res;
rctx->t_dst[i].len = digestsize / 4;
+ sg = sg_next(sg);
+ i++;
}
if (len > 0) {
dev_err(ss->dev, "remaining len %d\n", len);