Skip to contentSkip to conversation

crypto: replace kmalloc and then memcpy with kmemdup

PATCH In review Mihnea Dobrescu-Balaur 3 participants 3 messages Mar 11, 2013 – Mar 21, 2013 Crypto API

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crypto: replace kmalloc and then memcpy with kmemdup

---
 drivers/crypto/ux500/hash/hash_core.c |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/crypto/ux500/hash/hash_core.c +1 -3
index 632c333..8d16d3a 100644
@@ -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;
Signature · 1 line
1.7.10.4