crypto: safexcel - Add error handling for dma_map_sg() calls
authorNikita Zhandarovich <n.zhandarovich@fintech.ru>
Fri, 1 Dec 2023 12:49:29 +0000 (04:49 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 25 Jan 2024 23:35:16 +0000 (15:35 -0800)
commit8084b788c2fb1260f7d44c032d5124680b20d2b2
tree064a4048a73031c7ce7ae8c85f74ede72aa33a0e
parente136daaa10e4c6c50a5c0fc9c5f89a6f988fe619
crypto: safexcel - Add error handling for dma_map_sg() calls

[ Upstream commit 87e02063d07708cac5bfe9fd3a6a242898758ac8 ]

Macro dma_map_sg() may return 0 on error. This patch enables
checks in case of the macro failure and ensures unmapping of
previously mapped buffers with dma_unmap_sg().

Found by Linux Verification Center (linuxtesting.org) with static
analysis tool SVACE.

Fixes: 49186a7d9e46 ("crypto: inside_secure - Avoid dma map if size is zero")
Signed-off-by: Nikita Zhandarovich <n.zhandarovich@fintech.ru>
Reviewed-by: Antoine Tenart <atenart@kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/crypto/inside-secure/safexcel_cipher.c