linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch 2/2] crypto: mxc-scc - fix unwinding in mxc_scc_crypto_register()
@ 2016-04-22 10:01 Dan Carpenter
  0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2016-04-22 10:01 UTC (permalink / raw)
  To: Herbert Xu, Steffen Trumtrar
  Cc: David S. Miller, linux-crypto, linux-kernel, kernel-janitors

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>

diff --git a/drivers/crypto/mxc-scc.c b/drivers/crypto/mxc-scc.c
index 9b348a7..ff383ef 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;

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2016-04-22 10:01 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-22 10:01 [patch 2/2] crypto: mxc-scc - fix unwinding in mxc_scc_crypto_register() Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).