* [PATCH] crypto: algapi - Use crypto_unregister_algs in crypto_register_algs
@ 2025-12-11 10:15 Thorsten Blum
2025-12-19 7:10 ` Herbert Xu
0 siblings, 1 reply; 2+ messages in thread
From: Thorsten Blum @ 2025-12-11 10:15 UTC (permalink / raw)
To: Herbert Xu, David S. Miller; +Cc: Thorsten Blum, linux-crypto, linux-kernel
Replace the for loop with a call to crypto_unregister_algs(). Return
'ret' immediately and remove the goto statement to simplify the error
handling code.
In crypto_unregister_algs(), unregister the algorithms in reverse order.
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
crypto/algapi.c | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/crypto/algapi.c b/crypto/algapi.c
index e604d0d8b7b4..ac4fc790687e 100644
--- a/crypto/algapi.c
+++ b/crypto/algapi.c
@@ -511,17 +511,13 @@ int crypto_register_algs(struct crypto_alg *algs, int count)
for (i = 0; i < count; i++) {
ret = crypto_register_alg(&algs[i]);
- if (ret)
- goto err;
+ if (ret) {
+ crypto_unregister_algs(algs, i);
+ return ret;
+ }
}
return 0;
-
-err:
- for (--i; i >= 0; --i)
- crypto_unregister_alg(&algs[i]);
-
- return ret;
}
EXPORT_SYMBOL_GPL(crypto_register_algs);
@@ -529,7 +525,7 @@ void crypto_unregister_algs(struct crypto_alg *algs, int count)
{
int i;
- for (i = 0; i < count; i++)
+ for (i = count - 1; i >= 0; --i)
crypto_unregister_alg(&algs[i]);
}
EXPORT_SYMBOL_GPL(crypto_unregister_algs);
--
Thorsten Blum <thorsten.blum@linux.dev>
GPG: 1D60 735E 8AEF 3BE4 73B6 9D84 7336 78FD 8DFE EAD4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] crypto: algapi - Use crypto_unregister_algs in crypto_register_algs
2025-12-11 10:15 [PATCH] crypto: algapi - Use crypto_unregister_algs in crypto_register_algs Thorsten Blum
@ 2025-12-19 7:10 ` Herbert Xu
0 siblings, 0 replies; 2+ messages in thread
From: Herbert Xu @ 2025-12-19 7:10 UTC (permalink / raw)
To: Thorsten Blum; +Cc: David S. Miller, linux-crypto, linux-kernel
On Thu, Dec 11, 2025 at 11:15:55AM +0100, Thorsten Blum wrote:
> Replace the for loop with a call to crypto_unregister_algs(). Return
> 'ret' immediately and remove the goto statement to simplify the error
> handling code.
>
> In crypto_unregister_algs(), unregister the algorithms in reverse order.
>
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> ---
> crypto/algapi.c | 14 +++++---------
> 1 file changed, 5 insertions(+), 9 deletions(-)
Patch applied. Thanks.
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-12-19 7:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-11 10:15 [PATCH] crypto: algapi - Use crypto_unregister_algs in crypto_register_algs Thorsten Blum
2025-12-19 7:10 ` Herbert Xu
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.