Skip to content

Commit 0ce9093

Browse files
tobluxherbertx
authored andcommitted
crypto: img-hash - Use unregister_ahashes in img_{un}register_algs
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>
1 parent dc8f3d9 commit 0ce9093

1 file changed

Lines changed: 7 additions & 14 deletions

File tree

drivers/crypto/img-hash.c

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -870,25 +870,18 @@ static int img_register_algs(struct img_hash_dev *hdev)
870870

871871
for (i = 0; i < ARRAY_SIZE(img_algs); i++) {
872872
err = crypto_register_ahash(&img_algs[i]);
873-
if (err)
874-
goto err_reg;
873+
if (err) {
874+
crypto_unregister_ahashes(img_algs, i);
875+
return err;
876+
}
875877
}
876-
return 0;
877878

878-
err_reg:
879-
for (; i--; )
880-
crypto_unregister_ahash(&img_algs[i]);
881-
882-
return err;
879+
return 0;
883880
}
884881

885-
static int img_unregister_algs(struct img_hash_dev *hdev)
882+
static void img_unregister_algs(struct img_hash_dev *hdev)
886883
{
887-
int i;
888-
889-
for (i = 0; i < ARRAY_SIZE(img_algs); i++)
890-
crypto_unregister_ahash(&img_algs[i]);
891-
return 0;
884+
crypto_unregister_ahashes(img_algs, ARRAY_SIZE(img_algs));
892885
}
893886

894887
static void img_hash_done_task(unsigned long data)

0 commit comments

Comments
 (0)