On Wed, Jun 10, 2020 at 02:54:32AM +0530, Ayush Sawal wrote: > 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.sa...@chelsio.com> > --- > drivers/crypto/chelsio/chcr_algo.c | 18 ++++++++++++++---- > 1 file changed, 14 insertions(+), 4 deletions(-) > > diff --git a/drivers/crypto/chelsio/chcr_algo.c > b/drivers/crypto/chelsio/chcr_algo.c > index f8b55137cf7d..4c2553672b6f 100644 > --- a/drivers/crypto/chelsio/chcr_algo.c > +++ b/drivers/crypto/chelsio/chcr_algo.c > @@ -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; > + }
This is wrong. cra_refcnt must not be used directly by drivers. Normally driver unregister is stopped by the module reference count. This is not the case for your driver because of the existence of a path of unregistration that is not tied to module removal. To support that properly, we need to add code to the Crypto API to handle this, as opposed to adding hacks to the driver. Thanks, -- Email: Herbert Xu <herb...@gondor.apana.org.au> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt