hash_algo_name[ima_hash_algo], rc);
                return rc;
        }
+       pr_info("Allocated hash algorithm: %s\n",
+               hash_algo_name[ima_hash_algo]);
        return 0;
 }
 
 
  *     implements the IMA hooks: ima_bprm_check, ima_file_mmap,
  *     and ima_file_check.
  */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/module.h>
 #include <linux/file.h>
 #include <linux/binfmts.h>
        ima_init_template_list();
        hash_setup(CONFIG_IMA_DEFAULT_HASH);
        error = ima_init();
+
+       if (error && strcmp(hash_algo_name[ima_hash_algo],
+                           CONFIG_IMA_DEFAULT_HASH) != 0) {
+               pr_info("Allocating %s failed, going to use default hash algorithm %s\n",
+                       hash_algo_name[ima_hash_algo], CONFIG_IMA_DEFAULT_HASH);
+               hash_setup_done = 0;
+               hash_setup(CONFIG_IMA_DEFAULT_HASH);
+               error = ima_init();
+       }
+
        if (!error) {
                ima_initialized = 1;
                ima_update_policy_flag();