mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] crypto: jitterentropy: Fix debugfs leak on register failure
@ 2026-10-25  3:18 Tang Bin
  2026-10-25 21:21 ` Eric Biggers
  0 siblings, 1 reply; 2+ messages in thread
From: Tang Bin @ 2026-10-25  3:18 UTC (permalink / raw)
  To: herbert, davem; +Cc: linux-crypto, linux-kernel, tangbin

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@cmss.chinamobile.com>
---
 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




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] crypto: jitterentropy: Fix debugfs leak on register failure
  2026-10-25  3:18 [PATCH] crypto: jitterentropy: Fix debugfs leak on register failure Tang Bin
@ 2026-10-25 21:21 ` Eric Biggers
  0 siblings, 0 replies; 2+ messages in thread
From: Eric Biggers @ 2026-10-25 21:21 UTC (permalink / raw)
  To: Tang Bin; +Cc: herbert, davem, linux-crypto, linux-kernel

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@cmss.chinamobile.com>
> ---
>  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@kernel.org/

- Eric

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-10-25 21:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-25  3:18 [PATCH] crypto: jitterentropy: Fix debugfs leak on register failure Tang Bin
2026-10-25 21:21 ` Eric Biggers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®