crypto: vmx - remove unnecessary check
authorTudor-Dan Ambarus <tudor.ambarus@microchip.com>
Fri, 16 Jun 2017 08:39:48 +0000 (11:39 +0300)
committerHerbert Xu <herbert@gondor.apana.org.au>
Tue, 20 Jun 2017 03:21:49 +0000 (11:21 +0800)
You can't reach init() if parent alg_name is invalid. Moreover,
cypto_alloc_base() will return ENOENT if alg_name is NULL.
Found while grasping the fallback mechanism.

Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/vmx/aes.c
drivers/crypto/vmx/aes_cbc.c
drivers/crypto/vmx/aes_ctr.c
drivers/crypto/vmx/aes_xts.c

index 022c7ab7351a08c4f6afdff324e0b51eb1214bb1..96072b9b55c43ee2d134f1451a25d56c2130ab8d 100644 (file)
@@ -37,15 +37,10 @@ struct p8_aes_ctx {
 
 static int p8_aes_init(struct crypto_tfm *tfm)
 {
-       const char *alg;
+       const char *alg = crypto_tfm_alg_name(tfm);
        struct crypto_cipher *fallback;
        struct p8_aes_ctx *ctx = crypto_tfm_ctx(tfm);
 
-       if (!(alg = crypto_tfm_alg_name(tfm))) {
-               printk(KERN_ERR "Failed to get algorithm name.\n");
-               return -ENOENT;
-       }
-
        fallback = crypto_alloc_cipher(alg, 0, CRYPTO_ALG_NEED_FALLBACK);
        if (IS_ERR(fallback)) {
                printk(KERN_ERR
index 72a26eb4e954669eadce7f735cb101dd2ec79d08..7394d35d5936aa403821b0a29bed5ee70e27668f 100644 (file)
@@ -39,15 +39,10 @@ struct p8_aes_cbc_ctx {
 
 static int p8_aes_cbc_init(struct crypto_tfm *tfm)
 {
-       const char *alg;
+       const char *alg = crypto_tfm_alg_name(tfm);
        struct crypto_skcipher *fallback;
        struct p8_aes_cbc_ctx *ctx = crypto_tfm_ctx(tfm);
 
-       if (!(alg = crypto_tfm_alg_name(tfm))) {
-               printk(KERN_ERR "Failed to get algorithm name.\n");
-               return -ENOENT;
-       }
-
        fallback = crypto_alloc_skcipher(alg, 0,
                        CRYPTO_ALG_ASYNC | CRYPTO_ALG_NEED_FALLBACK);
 
index 7cf6d31c1123a117d55dc3de87ed543a3c6279a6..9c26d9e8dbea76ed49ac55bab94984c4a55767b9 100644 (file)
@@ -36,15 +36,10 @@ struct p8_aes_ctr_ctx {
 
 static int p8_aes_ctr_init(struct crypto_tfm *tfm)
 {
-       const char *alg;
+       const char *alg = crypto_tfm_alg_name(tfm);
        struct crypto_blkcipher *fallback;
        struct p8_aes_ctr_ctx *ctx = crypto_tfm_ctx(tfm);
 
-       if (!(alg = crypto_tfm_alg_name(tfm))) {
-               printk(KERN_ERR "Failed to get algorithm name.\n");
-               return -ENOENT;
-       }
-
        fallback =
            crypto_alloc_blkcipher(alg, 0, CRYPTO_ALG_NEED_FALLBACK);
        if (IS_ERR(fallback)) {
index 6adc9290557a4a5380223a7397186cbb144b556b..8cd6e62e4c909b95373a60e0bfc8063002b5dda1 100644 (file)
@@ -41,15 +41,10 @@ struct p8_aes_xts_ctx {
 
 static int p8_aes_xts_init(struct crypto_tfm *tfm)
 {
-       const char *alg;
+       const char *alg = crypto_tfm_alg_name(tfm);
        struct crypto_skcipher *fallback;
        struct p8_aes_xts_ctx *ctx = crypto_tfm_ctx(tfm);
 
-       if (!(alg = crypto_tfm_alg_name(tfm))) {
-               printk(KERN_ERR "Failed to get algorithm name.\n");
-               return -ENOENT;
-       }
-
        fallback = crypto_alloc_skcipher(alg, 0,
                        CRYPTO_ALG_ASYNC | CRYPTO_ALG_NEED_FALLBACK);
        if (IS_ERR(fallback)) {