Re: [PATCH] crypto: drbg - convert to guard(mutex)
From: Herbert Xu
Date: Fri Feb 27 2026 - 22:57:27 EST
On Sun, Feb 08, 2026 at 04:59:25AM +0530, Rajveer Chaudhari wrote:
> Replaced old manual mutex locking/unlocking with
> new safe guard(mutex) in drbg_instantiate().
> This ensures mutex gets unlocked on every return and prevents deadlocks.
>
> Signed-off-by: Rajveer Chaudhari <rajveer.chaudhari.linux@xxxxxxxxx>
> ---
> crypto/drbg.c | 11 +++--------
> 1 file changed, 3 insertions(+), 8 deletions(-)
>
> diff --git a/crypto/drbg.c b/crypto/drbg.c
> index 1d433dae9955..d52a7bd07322 100644
> --- a/crypto/drbg.c
> +++ b/crypto/drbg.c
> @@ -103,6 +103,7 @@
> #include <linux/kernel.h>
> #include <linux/jiffies.h>
> #include <linux/string_choices.h>
> +#include <linux/cleanup.h>
Please keep the headers sorted alphabetically.
> free_everything:
> - mutex_unlock(&drbg->drbg_mutex);
> drbg_uninstantiate(drbg);
> return ret;
This is a subtle change and now drbg_uninstantiate will be called
within the critical section. Are you sure this is safe?
Cheers,
--
Email: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt