crypto: omap-sham - fix very small data size handling
authorTero Kristo <t-kristo@ti.com>
Wed, 27 May 2020 12:24:27 +0000 (15:24 +0300)
committerHerbert Xu <herbert@gondor.apana.org.au>
Thu, 4 Jun 2020 12:03:41 +0000 (22:03 +1000)
With very small data sizes, the whole data can end up in the xmit
buffer. This code path does not set the sg_len properly which causes the
core dma framework to crash. Fix by adding the proper size in place.
Also, the data length must be a multiple of block-size, so extend the
DMA data size while here.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/omap-sham.c

index 5efc66c..45bc551 100644 (file)
@@ -752,9 +752,11 @@ static int omap_sham_align_sgs(struct scatterlist *sg,
 
        if (!sg || !sg->length || !nbytes) {
                if (bufcnt) {
+                       bufcnt = DIV_ROUND_UP(bufcnt, bs) * bs;
                        sg_init_table(rctx->sgl, 1);
                        sg_set_buf(rctx->sgl, rctx->dd->xmit_buf, bufcnt);
                        rctx->sg = rctx->sgl;
+                       rctx->sg_len = 1;
                }
 
                return 0;