linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tero Kristo <t-kristo@ti.com>
To: <herbert@gondor.apana.org.au>, <davem@davemloft.net>,
	<linux-crypto@vger.kernel.org>
Cc: <linux-omap@vger.kernel.org>
Subject: [PATCHv2 6/7] crypto: omap-aes: prevent unregistering algorithms twice
Date: Mon, 11 May 2020 14:19:12 +0300	[thread overview]
Message-ID: <20200511111913.26541-7-t-kristo@ti.com> (raw)
In-Reply-To: <20200511111913.26541-1-t-kristo@ti.com>

Most of the OMAP family SoCs contain two instances for AES core, which
causes the remove callbacks to be also done twice when driver is
removed. Fix the algorithm unregister callbacks to take into account the
number of algorithms still registered to avoid removing these twice.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
---
 drivers/crypto/omap-aes.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/crypto/omap-aes.c b/drivers/crypto/omap-aes.c
index 824ddf2a66ff..b5aff20c5900 100644
--- a/drivers/crypto/omap-aes.c
+++ b/drivers/crypto/omap-aes.c
@@ -1269,13 +1269,17 @@ static int omap_aes_remove(struct platform_device *pdev)
 	spin_unlock(&list_lock);
 
 	for (i = dd->pdata->algs_info_size - 1; i >= 0; i--)
-		for (j = dd->pdata->algs_info[i].registered - 1; j >= 0; j--)
+		for (j = dd->pdata->algs_info[i].registered - 1; j >= 0; j--) {
 			crypto_unregister_skcipher(
 					&dd->pdata->algs_info[i].algs_list[j]);
+			dd->pdata->algs_info[i].registered--;
+		}
 
-	for (i = dd->pdata->aead_algs_info->size - 1; i >= 0; i--) {
+	for (i = dd->pdata->aead_algs_info->registered - 1; i >= 0; i--) {
 		aalg = &dd->pdata->aead_algs_info->algs_list[i];
 		crypto_unregister_aead(aalg);
+		dd->pdata->aead_algs_info->registered--;
+
 	}
 
 	crypto_engine_exit(dd->engine);
-- 
2.17.1

--
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

  parent reply	other threads:[~2020-05-11 11:19 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-11 11:19 [PATCHv2 0/7] crypto: omap: sha/aes fixes Tero Kristo
2020-05-11 11:19 ` [PATCHv2 1/7] crypto: omap-aes: avoid spamming console with self tests Tero Kristo
2020-05-11 11:19 ` [PATCHv2 2/7] crypto: omap-sham: force kernel driver usage for sha algos Tero Kristo
2020-05-11 11:19 ` [PATCHv2 3/7] crypto: omap-crypto: fix userspace copied buffer access Tero Kristo
2020-05-22 13:12   ` Herbert Xu
2020-05-26 12:27     ` Tero Kristo
2020-05-26 12:35       ` Herbert Xu
2020-05-26 12:57         ` Tero Kristo
2020-05-26 13:07           ` Herbert Xu
2020-05-26 13:11             ` Tero Kristo
2020-05-26 14:21     ` [PATCHv3 " Tero Kristo
2020-05-27  2:20       ` Herbert Xu
2020-05-11 11:19 ` [PATCHv2 4/7] crypto: omap-sham: huge buffer access fixes Tero Kristo
2020-05-11 11:19 ` [PATCHv2 5/7] crypto: omap-sham: fix very small data size handling Tero Kristo
2020-05-11 11:19 ` Tero Kristo [this message]
2020-05-11 11:19 ` [PATCHv2 7/7] crypto: omap-sham: add proper load balancing support for multicore Tero Kristo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200511111913.26541-7-t-kristo@ti.com \
    --to=t-kristo@ti.com \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).