[cyrpto]: fix bad ERRPTR check in prng
From: Neil Horman
Date: Tue Jul 15 2008 - 11:32:53 EST
Patch to correct a bad return code check from crypto_alloc_blkcipher
Also correct Kconfig to pull in the needed ciphers to make prng work when its
enabled
Signed-off-by: Neil Horman <nhorman@xxxxxxxxxxxxx
Kconfig | 3 +++
prng.c | 8 ++++++--
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/crypto/Kconfig b/crypto/Kconfig
index ea50357..91e0d07 100644
--- a/crypto/Kconfig
+++ b/crypto/Kconfig
@@ -670,6 +670,9 @@ comment "Random Number Generation"
config CRYPTO_PRNG
tristate "Pseudo Random Number Generation for Cryptographic modules"
+ select CRYPTO_AES
+ select CRYPTO_CTR
+ depends on CRYPTO
help
This option enables the generic pseudo random number generator
for cryptographic modules. Uses the Algorithm specified in
diff --git a/crypto/prng.c b/crypto/prng.c
index 11b9306..b28f89a 100644
--- a/crypto/prng.c
+++ b/crypto/prng.c
@@ -300,6 +300,9 @@ struct prng_context *alloc_prng_context(void)
struct prng_context *ctx = kzalloc(sizeof(struct prng_context),
GFP_KERNEL);
+ if (!ctx)
+ return NULL;
+
spin_lock_init(&ctx->prng_lock);
if (reset_prng_context(ctx, NULL, NULL, NULL, NULL)) {
@@ -357,9 +360,10 @@ int reset_prng_context(struct prng_context *ctx,
crypto_free_blkcipher(ctx->tfm);
ctx->tfm = crypto_alloc_blkcipher("rfc3686(ctr(aes))", 0, 0);
- if (!ctx->tfm) {
+ if (IS_ERR(ctx->tfm)) {
dbgprint(KERN_CRIT "Failed to alloc tfm for context %p\n",
- ctx->tfm);
+ ctx);
+ ctx->tfm = NULL;
goto out;
}
--
/****************************************************
* Neil Horman <nhorman@xxxxxxxxxxxxx>
* Software Engineer, Red Hat
****************************************************/
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/