Commit 8b9914cd authored by Ayush Sawal's avatar Ayush Sawal Committed by David S. Miller

Crypto/chcr: Checking cra_refcnt before unregistering the algorithms

This patch puts a check for algorithm unregister, to avoid removal of
driver if the algorithm is under use.
Signed-off-by: default avatarAyush Sawal <ayush.sawal@chelsio.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent fb90a1c8
...@@ -4391,22 +4391,32 @@ static int chcr_unregister_alg(void) ...@@ -4391,22 +4391,32 @@ static int chcr_unregister_alg(void)
for (i = 0; i < ARRAY_SIZE(driver_algs); i++) { for (i = 0; i < ARRAY_SIZE(driver_algs); i++) {
switch (driver_algs[i].type & CRYPTO_ALG_TYPE_MASK) { switch (driver_algs[i].type & CRYPTO_ALG_TYPE_MASK) {
case CRYPTO_ALG_TYPE_SKCIPHER: case CRYPTO_ALG_TYPE_SKCIPHER:
if (driver_algs[i].is_registered) if (driver_algs[i].is_registered && refcount_read(
&driver_algs[i].alg.skcipher.base.cra_refcnt)
== 1) {
crypto_unregister_skcipher( crypto_unregister_skcipher(
&driver_algs[i].alg.skcipher); &driver_algs[i].alg.skcipher);
driver_algs[i].is_registered = 0;
}
break; break;
case CRYPTO_ALG_TYPE_AEAD: case CRYPTO_ALG_TYPE_AEAD:
if (driver_algs[i].is_registered) if (driver_algs[i].is_registered && refcount_read(
&driver_algs[i].alg.aead.base.cra_refcnt) == 1) {
crypto_unregister_aead( crypto_unregister_aead(
&driver_algs[i].alg.aead); &driver_algs[i].alg.aead);
driver_algs[i].is_registered = 0;
}
break; break;
case CRYPTO_ALG_TYPE_AHASH: case CRYPTO_ALG_TYPE_AHASH:
if (driver_algs[i].is_registered) if (driver_algs[i].is_registered && refcount_read(
&driver_algs[i].alg.hash.halg.base.cra_refcnt)
== 1) {
crypto_unregister_ahash( crypto_unregister_ahash(
&driver_algs[i].alg.hash); &driver_algs[i].alg.hash);
driver_algs[i].is_registered = 0;
}
break; break;
} }
driver_algs[i].is_registered = 0;
} }
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment