Skip to content

Commit

Permalink
crypto: mxc-scc - fix unwinding in mxc_scc_crypto_register()
Browse files Browse the repository at this point in the history
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: d293b64 ('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>
  • Loading branch information
Dan Carpenter authored and Herbert Xu committed Apr 25, 2016
1 parent b908bd3 commit 4c048af
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/crypto/mxc-scc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand All @@ -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;
Expand Down

0 comments on commit 4c048af

Please sign in to comment.