mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-02 08:34:20 +08:00
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: Ayush Sawal <ayush.sawal@chelsio.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
fb90a1c85d
commit
8b9914cd72
@ -4391,22 +4391,32 @@ static int chcr_unregister_alg(void)
|
||||
for (i = 0; i < ARRAY_SIZE(driver_algs); i++) {
|
||||
switch (driver_algs[i].type & CRYPTO_ALG_TYPE_MASK) {
|
||||
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(
|
||||
&driver_algs[i].alg.skcipher);
|
||||
driver_algs[i].is_registered = 0;
|
||||
}
|
||||
break;
|
||||
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(
|
||||
&driver_algs[i].alg.aead);
|
||||
driver_algs[i].is_registered = 0;
|
||||
}
|
||||
break;
|
||||
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(
|
||||
&driver_algs[i].alg.hash);
|
||||
driver_algs[i].is_registered = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
driver_algs[i].is_registered = 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user