* [PATCH] crypto: img-hash - Use unregister_ahashes in img_{un}register_algs
@ 2026-02-01 17:56 Thorsten Blum
2026-02-06 11:02 ` Herbert Xu
0 siblings, 1 reply; 2+ messages in thread
From: Thorsten Blum @ 2026-02-01 17:56 UTC (permalink / raw)
To: Herbert Xu, David S. Miller; +Cc: Thorsten Blum, linux-crypto, linux-kernel
Replace the for loops with calls to crypto_unregister_ahashes(). In
img_register_algs(), return 'err' immediately and remove the goto
statement to simplify the error handling code.
Convert img_unregister_algs() to a void function since its return value
is never used.
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
drivers/crypto/img-hash.c | 21 +++++++--------------
1 file changed, 7 insertions(+), 14 deletions(-)
diff --git a/drivers/crypto/img-hash.c b/drivers/crypto/img-hash.c
index f22c12e36b56..7195c37dd102 100644
--- a/drivers/crypto/img-hash.c
+++ b/drivers/crypto/img-hash.c
@@ -870,25 +870,18 @@ static int img_register_algs(struct img_hash_dev *hdev)
for (i = 0; i < ARRAY_SIZE(img_algs); i++) {
err = crypto_register_ahash(&img_algs[i]);
- if (err)
- goto err_reg;
+ if (err) {
+ crypto_unregister_ahashes(img_algs, i);
+ return err;
+ }
}
- return 0;
-err_reg:
- for (; i--; )
- crypto_unregister_ahash(&img_algs[i]);
-
- return err;
+ return 0;
}
-static int img_unregister_algs(struct img_hash_dev *hdev)
+static void img_unregister_algs(struct img_hash_dev *hdev)
{
- int i;
-
- for (i = 0; i < ARRAY_SIZE(img_algs); i++)
- crypto_unregister_ahash(&img_algs[i]);
- return 0;
+ crypto_unregister_ahashes(img_algs, ARRAY_SIZE(img_algs));
}
static void img_hash_done_task(unsigned long data)
--
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: img-hash - Use unregister_ahashes in img_{un}register_algs
2026-02-01 17:56 [PATCH] crypto: img-hash - Use unregister_ahashes in img_{un}register_algs Thorsten Blum
@ 2026-02-06 11:02 ` Herbert Xu
0 siblings, 0 replies; 2+ messages in thread
From: Herbert Xu @ 2026-02-06 11:02 UTC (permalink / raw)
To: Thorsten Blum; +Cc: David S. Miller, linux-crypto, linux-kernel
On Sun, Feb 01, 2026 at 06:56:33PM +0100, Thorsten Blum wrote:
> Replace the for loops with calls to crypto_unregister_ahashes(). In
> img_register_algs(), return 'err' immediately and remove the goto
> statement to simplify the error handling code.
>
> Convert img_unregister_algs() to a void function since its return value
> is never used.
>
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> ---
> drivers/crypto/img-hash.c | 21 +++++++--------------
> 1 file changed, 7 insertions(+), 14 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:[~2026-02-06 11:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-01 17:56 [PATCH] crypto: img-hash - Use unregister_ahashes in img_{un}register_algs Thorsten Blum
2026-02-06 11:02 ` Herbert Xu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox