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

crypto: mxc-scc - fix unwinding in mxc_scc_crypto_register()

There are two issues here:

1) We need to decrement "i" otherwise we unregister something that was
not successfully registered.
2) The original code did not unregister the first element in the array
where i is zero.

Fixes: d293b640ebd5 ('crypto: mxc-scc - add basic driver for the MXC SCC')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Dan Carpenter and committed by
Herbert Xu
4c048af7 b908bd3d

+2 -2
+2 -2
drivers/crypto/mxc-scc.c
··· 616 616 617 617 static int mxc_scc_crypto_register(struct mxc_scc *scc) 618 618 { 619 - unsigned int i; 619 + int i; 620 620 int err = 0; 621 621 622 622 for (i = 0; i < ARRAY_SIZE(scc_crypto_algs); i++) { ··· 629 629 return 0; 630 630 631 631 err_out: 632 - for (; i > 0; i--) 632 + while (--i >= 0) 633 633 crypto_unregister_alg(&scc_crypto_algs[i]->alg); 634 634 635 635 return err;