Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 02746970 authored by Ovidiu Panait's avatar Ovidiu Panait Committed by Greg Kroah-Hartman
Browse files

crypto: sahara - fix wait_for_completion_timeout() error handling



[ Upstream commit 2dba8e1d1a7957dcbe7888846268538847b471d1 ]

The sg lists are not unmapped in case of timeout errors. Fix this.

Fixes: 5a2bb93f ("crypto: sahara - add support for SHA1/256")
Fixes: 5de88752 ("crypto: sahara - Add driver for SAHARA2 accelerator.")
Signed-off-by: default avatarOvidiu Panait <ovidiu.panait@windriver.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent b588ed19
Loading
Loading
Loading
Loading
+10 −8
Original line number Diff line number Diff line
@@ -580,16 +580,17 @@ static int sahara_aes_process(struct ablkcipher_request *req)

	timeout = wait_for_completion_timeout(&dev->dma_completion,
				msecs_to_jiffies(SAHARA_TIMEOUT_MS));
	if (!timeout) {
		dev_err(dev->device, "AES timeout\n");
		return -ETIMEDOUT;
	}

	dma_unmap_sg(dev->device, dev->out_sg, dev->nb_out_sg,
		DMA_FROM_DEVICE);
	dma_unmap_sg(dev->device, dev->in_sg, dev->nb_in_sg,
		DMA_TO_DEVICE);

	if (!timeout) {
		dev_err(dev->device, "AES timeout\n");
		return -ETIMEDOUT;
	}

	return 0;
}

@@ -1023,15 +1024,16 @@ static int sahara_sha_process(struct ahash_request *req)

	timeout = wait_for_completion_timeout(&dev->dma_completion,
				msecs_to_jiffies(SAHARA_TIMEOUT_MS));
	if (!timeout) {
		dev_err(dev->device, "SHA timeout\n");
		return -ETIMEDOUT;
	}

	if (rctx->sg_in_idx)
		dma_unmap_sg(dev->device, dev->in_sg, dev->nb_in_sg,
			     DMA_TO_DEVICE);

	if (!timeout) {
		dev_err(dev->device, "SHA timeout\n");
		return -ETIMEDOUT;
	}

	memcpy(rctx->context, dev->context_base, rctx->context_size);

	if (req->result && rctx->last)