From c29fcecaf8a9e92adb41d3e2b9d6af9b2e04a385 Mon Sep 17 00:00:00 2001 From: Thorsten Blum Date: Fri, 19 Dec 2025 15:51:19 +0100 Subject: [PATCH] crypto: shash - Use unregister_shashes in register_shashes Replace the for loop with a call to crypto_unregister_shashes(). Return 'ret' immediately and remove the goto statement to simplify the error handling code. No functional changes. Signed-off-by: Thorsten Blum Signed-off-by: Herbert Xu --- crypto/shash.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/crypto/shash.c b/crypto/shash.c index 4721f5f134f4d..5238e0def4fd2 100644 --- a/crypto/shash.c +++ b/crypto/shash.c @@ -542,17 +542,13 @@ int crypto_register_shashes(struct shash_alg *algs, int count) for (i = 0; i < count; i++) { ret = crypto_register_shash(&algs[i]); - if (ret) - goto err; + if (ret) { + crypto_unregister_shashes(algs, i); + return ret; + } } return 0; - -err: - for (--i; i >= 0; --i) - crypto_unregister_shash(&algs[i]); - - return ret; } EXPORT_SYMBOL_GPL(crypto_register_shashes); -- 2.47.3