From: Gilad Ben-Yossef Date: Thu, 17 Feb 2022 19:27:26 +0000 (+0200) Subject: crypto: ccree - don't attempt 0 len DMA mappings X-Git-Tag: v5.18-rc1~199^2~53 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1fb37b5692c915edcc2448a6b37255738c7c77e0;p=thirdparty%2Flinux.git crypto: ccree - don't attempt 0 len DMA mappings 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: Gilad Ben-Yossef Reported-by: Corentin Labbe Fixes: ce0fc6db38de ("crypto: ccree - protect against empty or NULL scatterlists") Tested-by: Corentin Labbe Signed-off-by: Herbert Xu --- diff --git a/drivers/crypto/ccree/cc_buffer_mgr.c b/drivers/crypto/ccree/cc_buffer_mgr.c index a5e041d9d2cf1..11e0278c8631d 100644 --- a/drivers/crypto/ccree/cc_buffer_mgr.c +++ b/drivers/crypto/ccree/cc_buffer_mgr.c @@ -258,6 +258,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;