crypto: sahara - fix processing hash requests with req->nbytes < sg->length
[ Upstream commit 7bafa74d1ba35dcc173e1ce915e983d65905f77e ]
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: 5a2bb93f59
("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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
Родитель
2dc0f23ac4
Коммит
a5e0e39dac
|
@ -777,6 +777,7 @@ static int sahara_sha_hw_links_create(struct sahara_dev *dev,
|
|||
int start)
|
||||
{
|
||||
struct scatterlist *sg;
|
||||
unsigned int len;
|
||||
unsigned int i;
|
||||
int ret;
|
||||
|
||||
|
@ -798,12 +799,14 @@ static int sahara_sha_hw_links_create(struct sahara_dev *dev,
|
|||
if (!ret)
|
||||
return -EFAULT;
|
||||
|
||||
len = rctx->total;
|
||||
for (i = start; i < dev->nb_in_sg + start; i++) {
|
||||
dev->hw_link[i]->len = sg->length;
|
||||
dev->hw_link[i]->len = min(len, sg->length);
|
||||
dev->hw_link[i]->p = sg->dma_address;
|
||||
if (i == (dev->nb_in_sg + start - 1)) {
|
||||
dev->hw_link[i]->next = 0;
|
||||
} else {
|
||||
len -= min(len, sg->length);
|
||||
dev->hw_link[i]->next = dev->hw_phys_link[i + 1];
|
||||
sg = sg_next(sg);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче