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

Commit 40e6d5d1 authored by Gilad Ben-Yossef's avatar Gilad Ben-Yossef Committed by Greg Kroah-Hartman
Browse files

crypto: ccree - don't attempt 0 len DMA mappings



[ Upstream commit 1fb37b5692c915edcc2448a6b37255738c7c77e0 ]

Refuse to try mapping zero bytes as this may cause a fault
on some configurations / platforms and it seems the prev.
attempt is not enough and we need to be more explicit.

Signed-off-by: default avatarGilad Ben-Yossef <gilad@benyossef.com>
Reported-by: default avatarCorentin Labbe <clabbe.montjoie@gmail.com>
Fixes: ce0fc6db38de ("crypto: ccree - protect against empty or NULL
scatterlists")
Tested-by: default avatarCorentin Labbe <clabbe.montjoie@gmail.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent c3a5acf9
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -295,6 +295,13 @@ static int cc_map_sg(struct device *dev, struct scatterlist *sg,
{
	int ret = 0;

	if (!nbytes) {
		*mapped_nents = 0;
		*lbytes = 0;
		*nents = 0;
		return 0;
	}

	*nents = cc_get_sgl_nents(dev, sg, nbytes, lbytes);
	if (*nents > max_sg_nents) {
		*nents = 0;