]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blobdiff - crypto/mcryptd.c
powerpc/perf: Avoid spurious PMU interrupts after idle
[mirror_ubuntu-zesty-kernel.git] / crypto / mcryptd.c
index 86fb59b109a996193eefde142abb89bc29e87258..c207458d62993350d9a0cfca5e1deca573b09c8c 100644 (file)
@@ -254,18 +254,22 @@ out_free_inst:
        goto out;
 }
 
-static inline void mcryptd_check_internal(struct rtattr **tb, u32 *type,
+static inline bool mcryptd_check_internal(struct rtattr **tb, u32 *type,
                                          u32 *mask)
 {
        struct crypto_attr_type *algt;
 
        algt = crypto_get_attr_type(tb);
        if (IS_ERR(algt))
-               return;
-       if ((algt->type & CRYPTO_ALG_INTERNAL))
-               *type |= CRYPTO_ALG_INTERNAL;
-       if ((algt->mask & CRYPTO_ALG_INTERNAL))
-               *mask |= CRYPTO_ALG_INTERNAL;
+               return false;
+
+       *type |= algt->type & CRYPTO_ALG_INTERNAL;
+       *mask |= algt->mask & CRYPTO_ALG_INTERNAL;
+
+       if (*type & *mask & CRYPTO_ALG_INTERNAL)
+               return true;
+       else
+               return false;
 }
 
 static int mcryptd_hash_init_tfm(struct crypto_tfm *tfm)
@@ -492,7 +496,8 @@ static int mcryptd_create_hash(struct crypto_template *tmpl, struct rtattr **tb,
        u32 mask = 0;
        int err;
 
-       mcryptd_check_internal(tb, &type, &mask);
+       if (!mcryptd_check_internal(tb, &type, &mask))
+               return -EINVAL;
 
        halg = ahash_attr_alg(tb[1], type, mask);
        if (IS_ERR(halg))
@@ -612,12 +617,7 @@ EXPORT_SYMBOL_GPL(mcryptd_alloc_ahash);
 
 int ahash_mcryptd_digest(struct ahash_request *desc)
 {
-       int err;
-
-       err = crypto_ahash_init(desc) ?:
-             ahash_mcryptd_finup(desc);
-
-       return err;
+       return crypto_ahash_init(desc) ?: ahash_mcryptd_finup(desc);
 }
 
 int ahash_mcryptd_update(struct ahash_request *desc)