Merge branch 'rc-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild
[firefly-linux-kernel-4.4.55.git] / crypto / shash.c
index 21fc12e2378f17340d40f264af6deeab51f214d5..f426330f101755493a529d4dd8f9bcd900b51f73 100644 (file)
@@ -534,9 +534,9 @@ static int crypto_shash_report(struct sk_buff *skb, struct crypto_alg *alg)
        rhash.blocksize = alg->cra_blocksize;
        rhash.digestsize = salg->digestsize;
 
-       NLA_PUT(skb, CRYPTOCFGA_REPORT_HASH,
-               sizeof(struct crypto_report_hash), &rhash);
-
+       if (nla_put(skb, CRYPTOCFGA_REPORT_HASH,
+                   sizeof(struct crypto_report_hash), &rhash))
+               goto nla_put_failure;
        return 0;
 
 nla_put_failure:
@@ -629,6 +629,42 @@ int crypto_unregister_shash(struct shash_alg *alg)
 }
 EXPORT_SYMBOL_GPL(crypto_unregister_shash);
 
+int crypto_register_shashes(struct shash_alg *algs, int count)
+{
+       int i, ret;
+
+       for (i = 0; i < count; i++) {
+               ret = crypto_register_shash(&algs[i]);
+               if (ret)
+                       goto err;
+       }
+
+       return 0;
+
+err:
+       for (--i; i >= 0; --i)
+               crypto_unregister_shash(&algs[i]);
+
+       return ret;
+}
+EXPORT_SYMBOL_GPL(crypto_register_shashes);
+
+int crypto_unregister_shashes(struct shash_alg *algs, int count)
+{
+       int i, ret;
+
+       for (i = count - 1; i >= 0; --i) {
+               ret = crypto_unregister_shash(&algs[i]);
+               if (ret)
+                       pr_err("Failed to unregister %s %s: %d\n",
+                              algs[i].base.cra_driver_name,
+                              algs[i].base.cra_name, ret);
+       }
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(crypto_unregister_shashes);
+
 int shash_register_instance(struct crypto_template *tmpl,
                            struct shash_instance *inst)
 {