Re: [PATCH] crypto: jitterentropy: Fix debugfs leak on register failure
From: Eric Biggers
Date: Sun Oct 25 2026 - 17:22:07 EST
On Sun, Oct 25, 2026 at 11:18:35AM +0800, Tang Bin wrote:
> jent_mod_init() calls jent_testing_init() to create debugfs entries, but on
> success of jent_entropy_init() it returns crypto_register_rng() directly.
> If registration fails the module does not load so jent_mod_exit() never
> runs, leaking the debugfs entries. Capture the return, call
> jent_testing_exit() on failure before returning.
>
> Fixes: dfc9fa91938b ("crypto: jitterentropy - avoid compiler warnings")
> Signed-off-by: Tang Bin <tangbin@xxxxxxxxxxxxxxxxxxxx>
> ---
> crypto/jitterentropy-kcapi.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/crypto/jitterentropy-kcapi.c b/crypto/jitterentropy-kcapi.c
> index 652852649..43a0694e6 100644
> --- a/crypto/jitterentropy-kcapi.c
> +++ b/crypto/jitterentropy-kcapi.c
> @@ -296,7 +296,10 @@ static int __init jent_mod_init(void)
> pr_info("jitterentropy: Initialization failed with host not compliant with requirements: %d\n", ret);
> return -EFAULT;
> }
> - return crypto_register_rng(&jent_alg);
> + ret = crypto_register_rng(&jent_alg);
> + if (ret)
> + jent_testing_exit();
> + return ret;
The call to crypto_register_rng() is already being removed by
https://lore.kernel.org/linux-crypto/20261018204618.104876-12-ebiggers@xxxxxxxxxx/
- Eric