public inbox for linux-crypto@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] crypto: drbg - drop useless check in drbg_get_random_bytes()
@ 2025-09-21 20:33 Sergey Shtylyov
  2025-09-22  1:39 ` Herbert Xu
  2025-09-22  6:19 ` Yann Droneaud
  0 siblings, 2 replies; 8+ messages in thread
From: Sergey Shtylyov @ 2025-09-21 20:33 UTC (permalink / raw)
  To: Herbert Xu, David S. Miller", linux-crypto; +Cc: Karina Yankevich

drbg_fips_continuous_test() only returns 0 and -EAGAIN, so an early return
from drbg_get_random_bytes() could never happen, so we can drop the result
check from the *do/while* loop...

Found by Linux Verification Center (linuxtesting.org) with the Svace static
analysis tool.

Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>

---
The patch is against the master branch of Linus Torvalds' linux.git repo
(I'm unable to use the other repos on git.kernel.org and I have to update
Linus' repo from GitHub).

 crypto/drbg.c |    2 --
 1 file changed, 2 deletions(-)

Index: linux/crypto/drbg.c
===================================================================
--- linux.orig/crypto/drbg.c
+++ linux/crypto/drbg.c
@@ -1067,8 +1067,6 @@ static inline int drbg_get_random_bytes(
 	do {
 		get_random_bytes(entropy, entropylen);
 		ret = drbg_fips_continuous_test(drbg, entropy);
-		if (ret && ret != -EAGAIN)
-			return ret;
 	} while (ret);
 
 	return 0;

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

end of thread, other threads:[~2025-12-15 15:21 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-21 20:33 [PATCH] crypto: drbg - drop useless check in drbg_get_random_bytes() Sergey Shtylyov
2025-09-22  1:39 ` Herbert Xu
2025-09-22 19:43   ` Sergey Shtylyov
2025-09-23  1:33     ` Herbert Xu
2025-12-12 20:30       ` Sergey Shtylyov
2025-12-15 15:21         ` Sergey Shtylyov
2025-09-22  6:19 ` Yann Droneaud
2025-09-22 14:26   ` Sergey Shtylyov

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