crypto: ux500 - replace kmalloc and then memcpy with kmemdup
authorMihnea Dobrescu-Balaur <mihneadb@gmail.com>
Mon, 11 Mar 2013 10:48:10 +0000 (12:48 +0200)
committerHerbert Xu <herbert@gondor.apana.org.au>
Thu, 21 Mar 2013 09:44:41 +0000 (17:44 +0800)
Signed-off-by: Mihnea Dobrescu-Balaur <mihneadb@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/ux500/hash/hash_core.c

index 632c333..8d16d3a 100644 (file)
@@ -1368,14 +1368,12 @@ static int hash_setkey(struct crypto_ahash *tfm,
        /**
         * Freed in final.
         */
-       ctx->key = kmalloc(keylen, GFP_KERNEL);
+       ctx->key = kmemdup(key, keylen, GFP_KERNEL);
        if (!ctx->key) {
                pr_err(DEV_DBG_NAME " [%s] Failed to allocate ctx->key "
                       "for %d\n", __func__, alg);
                return -ENOMEM;
        }
-
-       memcpy(ctx->key, key, keylen);
        ctx->keylen = keylen;
 
        return ret;