PCI: rockchip: remove redundant platform data assignment
[firefly-linux-kernel-4.4.55.git] / crypto / api.c
index 3b6180336d3d54b9011bb8f90d15a220cf06b642..bbc147cb5dec87affad82510412459c075056f86 100644 (file)
@@ -34,6 +34,8 @@ EXPORT_SYMBOL_GPL(crypto_alg_sem);
 BLOCKING_NOTIFIER_HEAD(crypto_chain);
 EXPORT_SYMBOL_GPL(crypto_chain);
 
+static struct crypto_alg *crypto_larval_wait(struct crypto_alg *alg);
+
 struct crypto_alg *crypto_mod_get(struct crypto_alg *alg)
 {
        return try_module_get(alg->cra_module) ? crypto_alg_get(alg) : NULL;
@@ -144,8 +146,11 @@ static struct crypto_alg *crypto_larval_add(const char *name, u32 type,
        }
        up_write(&crypto_alg_sem);
 
-       if (alg != &larval->alg)
+       if (alg != &larval->alg) {
                kfree(larval);
+               if (crypto_is_larval(alg))
+                       alg = crypto_larval_wait(alg);
+       }
 
        return alg;
 }
@@ -167,7 +172,7 @@ static struct crypto_alg *crypto_larval_wait(struct crypto_alg *alg)
        struct crypto_larval *larval = (void *)alg;
        long timeout;
 
-       timeout = wait_for_completion_interruptible_timeout(
+       timeout = wait_for_completion_killable_timeout(
                &larval->completion, 60 * HZ);
 
        alg = larval->adult;
@@ -211,11 +216,11 @@ struct crypto_alg *crypto_larval_lookup(const char *name, u32 type, u32 mask)
 
        alg = crypto_alg_lookup(name, type, mask);
        if (!alg) {
-               request_module("%s", name);
+               request_module("crypto-%s", name);
 
                if (!((type ^ CRYPTO_ALG_NEED_FALLBACK) & mask &
                      CRYPTO_ALG_NEED_FALLBACK))
-                       request_module("%s-all", name);
+                       request_module("crypto-%s-all", name);
 
                alg = crypto_alg_lookup(name, type, mask);
        }
@@ -252,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;
@@ -391,7 +406,7 @@ EXPORT_SYMBOL_GPL(__crypto_alloc_tfm);
  *     @mask: Mask for type comparison
  *
  *     This function should not be used by new algorithm types.
- *     Plesae use crypto_alloc_tfm instead.
+ *     Please use crypto_alloc_tfm instead.
  *
  *     crypto_alloc_base() will first attempt to locate an already loaded
  *     algorithm.  If that fails and the kernel supports dynamically loadable
@@ -430,7 +445,7 @@ struct crypto_tfm *crypto_alloc_base(const char *alg_name, u32 type, u32 mask)
 err:
                if (err != -EAGAIN)
                        break;
-               if (signal_pending(current)) {
+               if (fatal_signal_pending(current)) {
                        err = -EINTR;
                        break;
                }
@@ -547,7 +562,7 @@ void *crypto_alloc_tfm(const char *alg_name,
 err:
                if (err != -EAGAIN)
                        break;
-               if (signal_pending(current)) {
+               if (fatal_signal_pending(current)) {
                        err = -EINTR;
                        break;
                }