drivers/crypto/img-hash.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-)
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
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
© 2016 - 2026 Red Hat, Inc.