[PATCH] crypto: jitterentropy: Fix debugfs leak on register failure

From: Tang Bin

Date: Sat Oct 24 2026 - 23:26:02 EST


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;
}

static void __exit jent_mod_exit(void)
--
2.52.0.windows.1