Skip to content

Commit

Permalink
crypto: sun8i-ss - handle zero sized sg
Browse files Browse the repository at this point in the history
sun8i-ss does not handle well the possible zero sized sg.

Fixes: d9b4541 ("crypto: sun8i-ss - support hash algorithms")
Signed-off-by: Corentin Labbe <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
  • Loading branch information
montjoie authored and herbertx committed May 13, 2022
1 parent 359e893 commit c149e47
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion drivers/crypto/allwinner/sun8i-ss/sun8i-ss-hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit c149e47

Please sign in to comment.