diff --git a/crypto/algapi.c b/crypto/algapi.c index 5c69ff8e8fa5..c72622f20f52 100644 --- a/crypto/algapi.c +++ b/crypto/algapi.c @@ -472,7 +472,9 @@ void crypto_unregister_alg(struct crypto_alg *alg) if (WARN(ret, "Algorithm %s is not registered", alg->cra_driver_name)) return; - BUG_ON(refcount_read(&alg->cra_refcnt) != 1); + if (WARN_ON(refcount_read(&alg->cra_refcnt) != 1)) + return; + if (alg->cra_destroy) alg->cra_destroy(alg);