From: Herbert Xu Date: Thu, 4 Jun 2026 04:30:54 +0000 (+0800) Subject: crypto: rng - Free default RNG on module exit X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=606ba888b98e0d26a2c4e5c8dc0542e3ad8f0f3a;p=thirdparty%2Flinux.git crypto: rng - Free default RNG on module exit When the rng module is removed the default RNG will be leaked. Call crypto_del_default_rng to free it if possible. Fixes: 7cecadb7cca8 ("crypto: rng - Do not free default RNG when it becomes unused") Signed-off-by: Herbert Xu --- diff --git a/crypto/rng.c b/crypto/rng.c index eec786c45bdd8..828b0d8074738 100644 --- a/crypto/rng.c +++ b/crypto/rng.c @@ -230,5 +230,16 @@ void crypto_unregister_rngs(struct rng_alg *algs, int count) } EXPORT_SYMBOL_GPL(crypto_unregister_rngs); +static void __exit rng_exit(void) +{ + int err; + + err = crypto_del_default_rng(); + if (err) + pr_err("Failed delete default RNG: %d\n", err); +} + +module_exit(rng_exit); + MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("Random Number Generator");