Skip to content

Commit 7bafa74

Browse files
opanait-wrherbertx
authored andcommitted
crypto: sahara - fix processing hash requests with req->nbytes < sg->length
It's not always the case that the entire sg entry needs to be processed. Currently, when nbytes is less than sg->length, "Descriptor length" errors are encountered. To fix this, take the actual request size into account when populating the hw links. Fixes: 5a2bb93 ("crypto: sahara - add support for SHA1/256") Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent 5deff02 commit 7bafa74

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

drivers/crypto/sahara.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -774,6 +774,7 @@ static int sahara_sha_hw_links_create(struct sahara_dev *dev,
774774
int start)
775775
{
776776
struct scatterlist *sg;
777+
unsigned int len;
777778
unsigned int i;
778779
int ret;
779780

@@ -795,12 +796,14 @@ static int sahara_sha_hw_links_create(struct sahara_dev *dev,
795796
if (!ret)
796797
return -EFAULT;
797798

799+
len = rctx->total;
798800
for (i = start; i < dev->nb_in_sg + start; i++) {
799-
dev->hw_link[i]->len = sg->length;
801+
dev->hw_link[i]->len = min(len, sg->length);
800802
dev->hw_link[i]->p = sg->dma_address;
801803
if (i == (dev->nb_in_sg + start - 1)) {
802804
dev->hw_link[i]->next = 0;
803805
} else {
806+
len -= min(len, sg->length);
804807
dev->hw_link[i]->next = dev->hw_phys_link[i + 1];
805808
sg = sg_next(sg);
806809
}

0 commit comments

Comments
 (0)