int alg_test(const char *driver, const char *alg, u32 type, u32 mask)
 {
        int i;
+       int rc;
 
        if ((type & CRYPTO_ALG_TYPE_MASK) == CRYPTO_ALG_TYPE_CIPHER) {
                char nalg[CRYPTO_MAX_ALG_NAME];
        if (i < 0)
                goto notest;
 
-       return alg_test_descs[i].test(alg_test_descs + i, driver,
+       rc = alg_test_descs[i].test(alg_test_descs + i, driver,
                                      type, mask);
+       if (fips_enabled && rc)
+               panic("%s: %s alg self test failed in fips mode!\n", driver, alg);
+
+       return rc;
 
 notest:
        printk(KERN_INFO "alg: No test for %s (%s)\n", alg, driver);