diff mbox series

[3/7] crypto: aes/x86 - eliminate set_key() handling for IRQ context

Message ID 1490554148-10953-4-git-send-email-ard.biesheuvel@linaro.org
State New
Headers show
Series crypto: aes - allow generic AES to be omitted | expand

Commit Message

Ard Biesheuvel March 26, 2017, 6:49 p.m. UTC
The crypto API does not allow setkey() to be used in interrupt context,
and so the fallback to crypto_aes_expand_key() is dead code which can
be eliminated. This removes a dependency on crypto_aes_expand_key()
which will be fulfilled by another driver after a subsequent patch.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

---
 arch/x86/crypto/aesni-intel_glue.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

-- 
2.7.4
diff mbox series

Patch

diff --git a/arch/x86/crypto/aesni-intel_glue.c b/arch/x86/crypto/aesni-intel_glue.c
index 93de8ea51548..f6bdd0ec96da 100644
--- a/arch/x86/crypto/aesni-intel_glue.c
+++ b/arch/x86/crypto/aesni-intel_glue.c
@@ -300,13 +300,13 @@  static int aes_set_key_common(struct crypto_tfm *tfm, void *raw_ctx,
 		return -EINVAL;
 	}
 
-	if (!irq_fpu_usable())
-		err = crypto_aes_expand_key(ctx, in_key, key_len);
-	else {
-		kernel_fpu_begin();
-		err = aesni_set_key(ctx, in_key, key_len);
-		kernel_fpu_end();
-	}
+	/* crypto API forbids setkey() in interrupt context */
+	if (WARN_ON(!irq_fpu_usable()))
+		return -EBUSY;
+
+	kernel_fpu_begin();
+	err = aesni_set_key(ctx, in_key, key_len);
+	kernel_fpu_end();
 
 	return err;
 }