diff options
author | Dan Carpenter <dan.carpenter@oracle.com> | 2016-04-22 13:01:39 +0300 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2016-04-25 19:14:53 +0800 |
commit | 4c048af708a8d562d02c5a2c8f46e01de6d81e34 (patch) | |
tree | 1dea07984a6be9bf8d09d7b6302f3d7bf662cd60 /drivers/crypto/mxc-scc.c | |
parent | b908bd3d4c4110a8a2ed84e2b6ab56fa7201db25 (diff) | |
download | linux-next-4c048af708a8d562d02c5a2c8f46e01de6d81e34.tar.gz |
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>
Diffstat (limited to 'drivers/crypto/mxc-scc.c')
-rw-r--r-- | drivers/crypto/mxc-scc.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/crypto/mxc-scc.c b/drivers/crypto/mxc-scc.c index 9b348a78dd23..ff383ef83871 100644 --- a/drivers/crypto/mxc-scc.c +++ b/drivers/crypto/mxc-scc.c @@ -616,7 +616,7 @@ static struct mxc_scc_crypto_tmpl *scc_crypto_algs[] = { static int mxc_scc_crypto_register(struct mxc_scc *scc) { - unsigned int i; + int i; int err = 0; for (i = 0; i < ARRAY_SIZE(scc_crypto_algs); i++) { @@ -629,7 +629,7 @@ static int mxc_scc_crypto_register(struct mxc_scc *scc) return 0; err_out: - for (; i > 0; i--) + while (--i >= 0) crypto_unregister_alg(&scc_crypto_algs[i]->alg); return err; |