Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

crypto: algapi - Use crypto_unregister_algs in crypto_register_algs

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>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Thorsten Blum and committed by
Herbert Xu
32c53988 0e602c5f

+5 -9
+5 -9
crypto/algapi.c
··· 511 511 512 512 for (i = 0; i < count; i++) { 513 513 ret = crypto_register_alg(&algs[i]); 514 - if (ret) 515 - goto err; 514 + if (ret) { 515 + crypto_unregister_algs(algs, i); 516 + return ret; 517 + } 516 518 } 517 519 518 520 return 0; 519 - 520 - err: 521 - for (--i; i >= 0; --i) 522 - crypto_unregister_alg(&algs[i]); 523 - 524 - return ret; 525 521 } 526 522 EXPORT_SYMBOL_GPL(crypto_register_algs); 527 523 ··· 525 529 { 526 530 int i; 527 531 528 - for (i = 0; i < count; i++) 532 + for (i = count - 1; i >= 0; --i) 529 533 crypto_unregister_alg(&algs[i]); 530 534 } 531 535 EXPORT_SYMBOL_GPL(crypto_unregister_algs);