Skip to contentSkip to conversation

cryptd: Fix uninitialized return value

PATCH In review Steffen Klassert 2 participants 3 messages Jul 15, 2009 Crypto API

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cryptd: Fix uninitialized return value

If cryptd_alloc_instance() fails, the return value is uninitialized. This patch fixes this by setting the return value.

---
 crypto/cryptd.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
crypto/cryptd.c +2 -0
index 5dabb7d..fbd26f9 100644
@@ -303,6 +303,7 @@ static int cryptd_create_blkcipher(struct crypto_template *tmpl,
 		return PTR_ERR(alg);
 
 	inst = cryptd_alloc_instance(alg, 0, sizeof(*ctx));
+	err = PTR_ERR(inst);
 	if (IS_ERR(inst))
 		goto out_put_alg;
 
@@ -522,6 +523,7 @@ static int cryptd_create_hash(struct crypto_template *tmpl, struct rtattr **tb,
 	alg = &salg->base;
 	inst = cryptd_alloc_instance(alg, ahash_instance_headroom(),
 				     sizeof(*ctx));
+	err = PTR_ERR(inst);
 	if (IS_ERR(inst))
 		goto out_put_alg;
 
Signature · 1 line
1.5.4.2
maintainer
#1 lore raw
Quoted 4 lines · Steffen Klassert

If cryptd_alloc_instance() fails, the return value is uninitialized. This patch fixes this by setting the return value.

Patch applied. Thanks Steffen!

Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
maintainer
#2 lore raw
In reply to Steffen Klassert
Quoted 4 lines · Steffen Klassert

If cryptd_alloc_instance() fails, the return value is uninitialized. This patch fixes this by setting the return value.

Just found two similar bugs in xcbc and hmac. I'll fix them up.

Thanks,

Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt