OSDN Git Service

crypto: testmgr - delay execution of set-up code
authorCristian Stoica <cristian.stoica@freescale.com>
Fri, 8 Aug 2014 11:27:52 +0000 (14:27 +0300)
committerHerbert Xu <herbert@gondor.apana.org.au>
Mon, 25 Aug 2014 12:27:18 +0000 (20:27 +0800)
Prepare IV array only if the dependent code is executed.

Signed-off-by: Cristian Stoica <cristian.stoica@freescale.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto/testmgr.c

index 7fe4225..f217c62 100644 (file)
@@ -961,16 +961,15 @@ static int __test_skcipher(struct crypto_ablkcipher *tfm, int enc,
 
        j = 0;
        for (i = 0; i < tcount; i++) {
+               if (template[i].np && !template[i].also_non_np)
+                       continue;
+
                if (template[i].iv)
                        memcpy(iv, template[i].iv, MAX_IVLEN);
                else
                        memset(iv, 0, MAX_IVLEN);
 
-               if (template[i].np && !template[i].also_non_np)
-                       continue;
-
                j++;
-
                ret = -EINVAL;
                if (WARN_ON(align_offset + template[i].ilen > PAGE_SIZE))
                        goto out;
@@ -1038,16 +1037,15 @@ static int __test_skcipher(struct crypto_ablkcipher *tfm, int enc,
                if (align_offset != 0)
                        break;
 
+               if (!template[i].np)
+                       continue;
+
                if (template[i].iv)
                        memcpy(iv, template[i].iv, MAX_IVLEN);
                else
                        memset(iv, 0, MAX_IVLEN);
 
-               if (!template[i].np)
-                       continue;
-
                j++;
-
                crypto_ablkcipher_clear_flags(tfm, ~0);
                if (template[i].wk)
                        crypto_ablkcipher_set_flags(tfm, CRYPTO_TFM_REQ_WEAK_KEY);