]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
crypto: img-hash - Use unregister_ahashes in img_{un}register_algs
authorThorsten Blum <thorsten.blum@linux.dev>
Sun, 1 Feb 2026 17:56:33 +0000 (18:56 +0100)
committerHerbert Xu <herbert@gondor.apana.org.au>
Sat, 7 Feb 2026 01:32:10 +0000 (09:32 +0800)
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>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/img-hash.c

index f22c12e36b56cc5d0e442f3fd2771550851a992f..7195c37dd102715d0e7ac43282ef235c74be8ae8 100644 (file)
@@ -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)