}
 
 /* ima_add_template_entry helper function:
- * - Add template entry to measurement list and hash table.
+ * - Add template entry to the measurement list and hash table, for
+ *   all entries except those carried across kexec.
  *
  * (Called with ima_extend_list_mutex held.)
  */
-static int ima_add_digest_entry(struct ima_template_entry *entry)
+static int ima_add_digest_entry(struct ima_template_entry *entry,
+                               bool update_htable)
 {
        struct ima_queue_entry *qe;
        unsigned int key;
        list_add_tail_rcu(&qe->later, &ima_measurements);
 
        atomic_long_inc(&ima_htable.len);
-       key = ima_hash_key(entry->digest);
-       hlist_add_head_rcu(&qe->hnext, &ima_htable.queue[key]);
+       if (update_htable) {
+               key = ima_hash_key(entry->digest);
+               hlist_add_head_rcu(&qe->hnext, &ima_htable.queue[key]);
+       }
        return 0;
 }
 
                }
        }
 
-       result = ima_add_digest_entry(entry);
+       result = ima_add_digest_entry(entry, 1);
        if (result < 0) {
                audit_cause = "ENOMEM";
                audit_info = 0;
        int result = 0;
 
        mutex_lock(&ima_extend_list_mutex);
-       result = ima_add_digest_entry(entry);
+       result = ima_add_digest_entry(entry, 0);
        mutex_unlock(&ima_extend_list_mutex);
        return result;
 }