Merge git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
[linux-3.10.git] / drivers / crypto / ux500 / hash / hash_core.c
index 1827e9f..cf55089 100644 (file)
@@ -938,6 +938,7 @@ static int hash_dma_final(struct ahash_request *req)
        if (!ctx->device->dma.nents) {
                dev_err(device_data->dev, "[%s] "
                                "ctx->device->dma.nents = 0", __func__);
+               ret = ctx->device->dma.nents;
                goto out;
        }
 
@@ -945,6 +946,7 @@ static int hash_dma_final(struct ahash_request *req)
        if (bytes_written != req->nbytes) {
                dev_err(device_data->dev, "[%s] "
                                "hash_dma_write() failed!", __func__);
+               ret = bytes_written;
                goto out;
        }
 
@@ -1367,14 +1369,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;