2009-07-15 08:47:30

by Steffen Klassert

[permalink] [raw]
Subject: [PATCH] cryptd: Fix uninitialized return value

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

Signed-off-by: Steffen Klassert <[email protected]>
---
crypto/cryptd.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/crypto/cryptd.c b/crypto/cryptd.c
index 5dabb7d..fbd26f9 100644
--- a/crypto/cryptd.c
+++ b/crypto/cryptd.c
@@ -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;

--
1.5.4.2



2009-07-15 08:50:02

by Herbert Xu

[permalink] [raw]
Subject: Re: [PATCH] cryptd: Fix uninitialized return value

On Wed, Jul 15, 2009 at 10:50:09AM +0200, Steffen Klassert wrote:
> If cryptd_alloc_instance() fails, the return value is uninitialized.
> This patch fixes this by setting the return value.
>
> Signed-off-by: Steffen Klassert <[email protected]>

Patch applied. Thanks Steffen!
--
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

2009-07-15 08:54:04

by Herbert Xu

[permalink] [raw]
Subject: Re: [PATCH] cryptd: Fix uninitialized return value

On Wed, Jul 15, 2009 at 10:50:09AM +0200, Steffen Klassert wrote:
> If cryptd_alloc_instance() fails, the return value is uninitialized.
> This patch fixes this by setting the return value.
>
> Signed-off-by: Steffen Klassert <[email protected]>

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

Thanks,
--
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