ima: free duplicate measurement memory
[pandora-kernel.git] / security / integrity / ima / ima_queue.c
index 46ba62b..e1a5062 100644 (file)
@@ -71,7 +71,7 @@ static int ima_add_digest_entry(struct ima_template_entry *entry)
 
        qe = kmalloc(sizeof(*qe), GFP_KERNEL);
        if (qe == NULL) {
-               pr_err("OUT OF MEMORY ERROR creating queue entry.\n");
+               pr_err("IMA: OUT OF MEMORY ERROR creating queue entry.\n");
                return -ENOMEM;
        }
        qe->entry = entry;
@@ -94,7 +94,7 @@ static int ima_pcr_extend(const u8 *hash)
 
        result = tpm_pcr_extend(TPM_ANY_NUM, CONFIG_IMA_MEASURE_PCR_IDX, hash);
        if (result != 0)
-               pr_err("Error Communicating to TPM chip\n");
+               pr_err("IMA: Error Communicating to TPM chip\n");
        return result;
 }
 
@@ -114,6 +114,7 @@ int ima_add_template_entry(struct ima_template_entry *entry, int violation,
                memcpy(digest, entry->digest, sizeof digest);
                if (ima_lookup_digest_entry(digest)) {
                        audit_cause = "hash_exists";
+                       result = -EEXIST;
                        goto out;
                }
        }