ANDROID: fips140: check for errors from initcalls

Check for errors when executing the initcalls so that we can't fail to
register some algorithms without noticing.

Bug: 153614920
Bug: 188620248
Change-Id: I8e55de3d7624c6700f161c92705d0f6f874476d8
Signed-off-by: Eric Biggers <ebiggers@google.com>
diff --git a/crypto/fips140-module.c b/crypto/fips140-module.c
index 8d8e723..a0e199b 100644
--- a/crypto/fips140-module.c
+++ b/crypto/fips140-module.c
@@ -539,8 +539,17 @@ fips140_init(void)
 	     initcall < &__initcall_end_marker;
 	     initcall++) {
 		int (*init)(void) = offset_to_ptr(initcall);
+		int err = init();
 
-		init();
+		/*
+		 * ENODEV is expected from initcalls that only register
+		 * algorithms that depend on non-present CPU features.  Besides
+		 * that, errors aren't expected here.
+		 */
+		if (err && err != -ENODEV) {
+			pr_err("initcall %ps() failed: %d\n", init, err);
+			goto panic;
+		}
 	}
 
 	if (!update_live_fips140_algos())