summaryrefslogtreecommitdiff
path: root/drivers/crypto
diff options
context:
space:
mode:
authorVarun Wadekar <vwadekar@nvidia.com>2011-12-12 12:32:36 +0530
committerVarun Colbert <vcolbert@nvidia.com>2012-01-20 13:43:42 -0800
commiteec952037457a08703c1aa736ac6fd2083a6bc34 (patch)
treebb43ee9bda1bd1fc0073d4400f6e46cd1941bc6b /drivers/crypto
parente9db109396e3f59fecfff476f53aad33650bff55 (diff)
crypto: tegra-aes: rng: check if bsea is busy before using it
Bug 917607 Change-Id: I7497411932b6ba8c155026f1662063e87c21eb40 Signed-off-by: Varun Wadekar <vwadekar@nvidia.com> Reviewed-on: http://git-master/r/74012 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: Sanjay Singh Rawat <srawat@nvidia.com>
Diffstat (limited to 'drivers/crypto')
-rw-r--r--drivers/crypto/tegra-aes.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/drivers/crypto/tegra-aes.c b/drivers/crypto/tegra-aes.c
index 31069558d9f1..13e5a4375cd1 100644
--- a/drivers/crypto/tegra-aes.c
+++ b/drivers/crypto/tegra-aes.c
@@ -938,7 +938,6 @@ static int tegra_aes_rng_reset(struct crypto_rng *tfm, u8 *seed,
struct tegra_aes_ctx *ctx = &rng_ctx;
struct tegra_aes_engine *eng = NULL;
struct tegra_aes_slot *key_slot;
- int bsev_busy = false;
int bsea_busy = false;
unsigned long flags;
struct timespec ts;
@@ -946,24 +945,21 @@ static int tegra_aes_rng_reset(struct crypto_rng *tfm, u8 *seed,
int ret = 0;
u8 *dt;
+ if (!dd)
+ return -EINVAL;
+
if (slen < (DEFAULT_RNG_BLK_SZ + AES_KEYSIZE_128)) {
return -ENOMEM;
}
spin_lock_irqsave(&dd->lock, flags);
- bsev_busy = test_and_set_bit(FLAGS_BUSY, &dd->bsev.busy);
- if (bsev_busy)
- bsea_busy = test_and_set_bit(FLAGS_BUSY, &dd->bsea.busy);
+ bsea_busy = test_and_set_bit(FLAGS_BUSY, &dd->bsea.busy);
spin_unlock_irqrestore(&dd->lock, flags);
- if (!bsev_busy) {
- eng = &dd->bsev;
- } else if (!bsea_busy) {
+ if (!bsea_busy)
eng = &dd->bsea;
- } else {
- dev_err(dd->dev, "%s: hardware engine is busy\n", __func__);
+ else
return -EBUSY;
- }
ctx->eng = eng;
dd->flags = FLAGS_ENCRYPT | FLAGS_RNG;