From: Ovidiu Panait Date: Sun, 24 Dec 2023 08:21:34 +0000 (+0200) Subject: crypto: sahara - improve error handling in sahara_sha_process() X-Git-Tag: v6.6.14~512 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3c3eb0f8bb26d0a8c19d778cf4e54e373bb57cd2;p=platform%2Fkernel%2Flinux-starfive.git crypto: sahara - improve error handling in sahara_sha_process() [ Upstream commit 5deff027fca49a1eb3b20359333cf2ae562a2343 ] sahara_sha_hw_data_descriptor_create() returns negative error codes on failure, so make sure the errors are correctly handled / propagated. Fixes: 5a2bb93f5992 ("crypto: sahara - add support for SHA1/256") Signed-off-by: Ovidiu Panait Signed-off-by: Herbert Xu Signed-off-by: Sasha Levin --- diff --git a/drivers/crypto/sahara.c b/drivers/crypto/sahara.c index 86ff5ad..117aa42 100644 --- a/drivers/crypto/sahara.c +++ b/drivers/crypto/sahara.c @@ -987,7 +987,10 @@ static int sahara_sha_process(struct ahash_request *req) return ret; if (rctx->first) { - sahara_sha_hw_data_descriptor_create(dev, rctx, req, 0); + ret = sahara_sha_hw_data_descriptor_create(dev, rctx, req, 0); + if (ret) + return ret; + dev->hw_desc[0]->next = 0; rctx->first = 0; } else { @@ -995,7 +998,10 @@ static int sahara_sha_process(struct ahash_request *req) sahara_sha_hw_context_descriptor_create(dev, rctx, req, 0); dev->hw_desc[0]->next = dev->hw_phys_desc[1]; - sahara_sha_hw_data_descriptor_create(dev, rctx, req, 1); + ret = sahara_sha_hw_data_descriptor_create(dev, rctx, req, 1); + if (ret) + return ret; + dev->hw_desc[1]->next = 0; }