crypto: omap-aes - prevent unregistering algorithms twice
authorTero Kristo <t-kristo@ti.com>
Wed, 27 May 2020 12:24:28 +0000 (15:24 +0300)
committerHerbert Xu <herbert@gondor.apana.org.au>
Thu, 4 Jun 2020 12:03:42 +0000 (22:03 +1000)
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>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/omap-aes.c

index 824ddf2a66ffdf4d1c64939760e4f4f6f3539999..b5aff20c59009193b6ed71c232b0c64072bdb965 100644 (file)
@@ -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);