[PATCH 16/30] crypto: sa2ul - fix resource leak of sha in init_alg() error path

From: Manorit Chawdhry

Date: Tue Sep 15 2026 - 06:39:36 EST


Add crypto_free_shash() call before returning the error to properly
clean up the resource allocated in the previous call.

Fixes: 2dc53d004745 ("crypto: sa2ul - add sha1/sha256/sha512 support")
Assisted-by: Sisyphus:claude-sonnet-4-6
Signed-off-by: Manorit Chawdhry <m-chawdhry@xxxxxx>
---
drivers/crypto/sa2ul.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/crypto/sa2ul.c b/drivers/crypto/sa2ul.c
index cd80a2dabc99..9379d1271698 100644
--- a/drivers/crypto/sa2ul.c
+++ b/drivers/crypto/sa2ul.c
@@ -1465,6 +1465,7 @@ static int sa_sha_cra_init_alg(struct crypto_tfm *tfm, const char *alg_base)
if (IS_ERR(ctx->fallback.ahash)) {
dev_err(ctx->dev_data->dev,
"Could not load fallback driver\n");
+ crypto_free_shash(ctx->shash);
return PTR_ERR(ctx->fallback.ahash);
}
}

--
2.43.0