[PATCH] crypto: shash - Handle failures in crypto_alloc_shash() correctly

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



crypto_alloc_tfm() returns an error-valued pointer in case of failure,
which must not be translated using __crypto_shash_cast().

Currently everything works fine because __crypto_shash_cast() is a no-op
(crypto_shash.base is at offset zero).

Signed-off-by: Geert Uytterhoeven <Geert.Uytterhoeven@xxxxxxxxxxx>
---
 crypto/shash.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/crypto/shash.c b/crypto/shash.c
index 13a0dc1..fbc6993 100644
--- a/crypto/shash.c
+++ b/crypto/shash.c
@@ -480,8 +480,12 @@ static const struct crypto_type crypto_shash_type = {
 struct crypto_shash *crypto_alloc_shash(const char *alg_name, u32 type,
 					u32 mask)
 {
-	return __crypto_shash_cast(
-		crypto_alloc_tfm(alg_name, &crypto_shash_type, type, mask));
+	struct crypto_tfm *tfm = crypto_alloc_tfm(alg_name, &crypto_shash_type,
+						  type, mask);
+	if (IS_ERR(tfm))
+		return ERR_CAST(tfm);
+
+	return __crypto_shash_cast(tfm);
 }
 EXPORT_SYMBOL_GPL(crypto_alloc_shash);
 
-- 
1.6.0.4

With kind regards,

Geert Uytterhoeven
Software Architect

Sony Techsoft Centre Europe
The Corporate Village · Da Vincilaan 7-D1 · B-1935 Zaventem · Belgium

Phone:    +32 (0)2 700 8453
Fax:      +32 (0)2 700 8622
E-mail:   Geert.Uytterhoeven@xxxxxxxxxxx
Internet: http://www.sony-europe.com/

A division of Sony Europe (Belgium) N.V.
VAT BE 0413.825.160 · RPR Brussels
Fortis · BIC GEBABEBB · IBAN BE41293037680010
--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Kernel]     [Gnu Classpath]     [Gnu Crypto]     [DM Crypt]     [Netfilter]     [Bugtraq]

  Powered by Linux