diff options
Diffstat (limited to 'drivers/crypto/nx/nx-aes-ecb.c')
-rw-r--r-- | drivers/crypto/nx/nx-aes-ecb.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/drivers/crypto/nx/nx-aes-ecb.c b/drivers/crypto/nx/nx-aes-ecb.c index 7bbc9a81da2..77dbe084ba4 100644 --- a/drivers/crypto/nx/nx-aes-ecb.c +++ b/drivers/crypto/nx/nx-aes-ecb.c @@ -70,10 +70,15 @@ static int ecb_aes_nx_crypt(struct blkcipher_desc *desc, { struct nx_crypto_ctx *nx_ctx = crypto_blkcipher_ctx(desc->tfm); struct nx_csbcpb *csbcpb = nx_ctx->csbcpb; + unsigned long irq_flags; int rc; - if (nbytes > nx_ctx->ap->databytelen) - return -EINVAL; + spin_lock_irqsave(&nx_ctx->lock, irq_flags); + + if (nbytes > nx_ctx->ap->databytelen) { + rc = -EINVAL; + goto out; + } if (enc) NX_CPB_FDM(csbcpb) |= NX_FDM_ENDE_ENCRYPT; @@ -98,6 +103,7 @@ static int ecb_aes_nx_crypt(struct blkcipher_desc *desc, atomic64_add(csbcpb->csb.processed_byte_count, &(nx_ctx->stats->aes_bytes)); out: + spin_unlock_irqrestore(&nx_ctx->lock, irq_flags); return rc; } |