From 6f95a9c58e440411f7e495582f405769369c6649 Mon Sep 17 00:00:00 2001 From: Daniel Pouzzner Date: Fri, 19 Dec 2025 10:30:14 -0600 Subject: [PATCH] wolfcrypt/src/random.c: in _InitRng(), remove "drbg_instantiated" conditional cleanup logic (Coverity true-benign-positive: DEADCODE because drbg_instantiated is always false when ret != DRBG_SUCCESS). --- wolfcrypt/src/random.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/wolfcrypt/src/random.c b/wolfcrypt/src/random.c index 2945a88b9..2b395c463 100644 --- a/wolfcrypt/src/random.c +++ b/wolfcrypt/src/random.c @@ -813,7 +813,6 @@ static int _InitRng(WC_RNG* rng, byte* nonce, word32 nonceSz, #ifdef HAVE_HASHDRBG word32 seedSz = SEED_SZ + SEED_BLOCK_SZ; WC_DECLARE_VAR(seed, byte, MAX_SEED_SZ, rng->heap); - int drbg_instantiated = 0; #ifdef WOLFSSL_SMALL_STACK_CACHE int drbg_scratch_instantiated = 0; #endif @@ -1020,8 +1019,6 @@ static int _InitRng(WC_RNG* rng, byte* nonce, word32 nonceSz, ret = Hash_DRBG_Instantiate((DRBG_internal *)rng->drbg, seed + SEED_BLOCK_SZ, seedSz - SEED_BLOCK_SZ, nonce, nonceSz, rng->heap, devId); - if (ret == 0) - drbg_instantiated = 1; } /* ret == 0 */ #ifdef WOLFSSL_SMALL_STACK @@ -1033,8 +1030,6 @@ static int _InitRng(WC_RNG* rng, byte* nonce, word32 nonceSz, WC_FREE_VAR_EX(seed, rng->heap, DYNAMIC_TYPE_SEED); if (ret != DRBG_SUCCESS) { - if (drbg_instantiated) - (void)Hash_DRBG_Uninstantiate((DRBG_internal *)rng->drbg); #if !defined(WOLFSSL_NO_MALLOC) || defined(WOLFSSL_STATIC_MEMORY) XFREE(rng->drbg, rng->heap, DYNAMIC_TYPE_RNG); #endif