Skip to contentSkip to conversation

crypto: DRBG - fix freeing of resources

PATCH In review Stephan Müller 2 participants 2 messages Sep 14, 2017 – Sep 21, 2017 Crypto API

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crypto: DRBG - fix freeing of resources

During the change to use aligned buffers, the deallocation code path was not updated correctly. The current code tries to free the aligned buffer pointer and not the original buffer pointer as it is supposed to.

Thus, the code is updated to free the original buffer pointer and set the aligned buffer pointer that is used throughout the code to NULL.

Fixes 3cfc3b9721123 ("crypto: drbg - use aligned buffers")
CC Herbert Xu <[email protected]>
---
 crypto/drbg.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
crypto/drbg.c +4 -4
index 633a88e93ab0..70018397e59a 100644
@@ -1133,10 +1133,10 @@ static inline void drbg_dealloc_state(struct drbg_state *drbg)
 {
 	if (!drbg)
 		return;
-	kzfree(drbg->V);
-	drbg->Vbuf = NULL;
-	kzfree(drbg->C);
-	drbg->Cbuf = NULL;
+	kzfree(drbg->Vbuf);
+	drbg->V = NULL;
+	kzfree(drbg->Cbuf);
+	drbg->C = NULL;
 	kzfree(drbg->scratchpadbuf);
 	drbg->scratchpadbuf = NULL;
 	drbg->reseed_ctr = 0;
Signature · 1 line
2.13.5
maintainer
#1 lore raw
Quoted 11 lines · Stephan Müller

During the change to use aligned buffers, the deallocation code path was not updated correctly. The current code tries to free the aligned buffer pointer and not the original buffer pointer as it is supposed to.

Thus, the code is updated to free the original buffer pointer and set the aligned buffer pointer that is used throughout the code to NULL.

Fixes 3cfc3b9721123 ("crypto: drbg - use aligned buffers")
CC Herbert Xu <[email protected]>

Patch applied. Thanks.

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt