ARC: Don't memzero twice in dma_alloc_coherent for __GFP_ZERO
[firefly-linux-kernel-4.4.55.git] / crypto / api.c
index 2a81e98a0021074b9ce8e2ac54eb876c1dcf7607..afe4610afc4b952d585ede5ba9cbd732f5aa3750 100644 (file)
@@ -257,6 +257,16 @@ struct crypto_alg *crypto_alg_mod_lookup(const char *name, u32 type, u32 mask)
                mask |= CRYPTO_ALG_TESTED;
        }
 
+       /*
+        * If the internal flag is set for a cipher, require a caller to
+        * to invoke the cipher with the internal flag to use that cipher.
+        * Also, if a caller wants to allocate a cipher that may or may
+        * not be an internal cipher, use type | CRYPTO_ALG_INTERNAL and
+        * !(mask & CRYPTO_ALG_INTERNAL).
+        */
+       if (!((type | mask) & CRYPTO_ALG_INTERNAL))
+               mask |= CRYPTO_ALG_INTERNAL;
+
        larval = crypto_larval_lookup(name, type, mask);
        if (IS_ERR(larval) || !crypto_is_larval(larval))
                return larval;