Commit 178554ae authored by Jesper Juhl's avatar Jesper Juhl Committed by Linus Torvalds

Memory leak in tpm_ascii_bios_measurements_open()

Coverity found a memory leak in tpm_ascii_bios_measurements_open().

If "read_log(log)" fails, then we may leak 'log' and
'log->bios_event_log'.
Signed-off-by: default avatarJesper Juhl <jesper.juhl@gmail.com>
Cc: Seiji Munetoh <munetoh@jp.ibm.com>
Cc: Stefan Berger <stefanb@us.ibm.com>
Cc: Reiner Sailer <sailer@watson.ibm.com>
Cc: Kylene Hall <kjhall@us.ibm.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 22982a56
No related merge requests found
...@@ -427,7 +427,7 @@ static int tpm_ascii_bios_measurements_open(struct inode *inode, ...@@ -427,7 +427,7 @@ static int tpm_ascii_bios_measurements_open(struct inode *inode,
return -ENOMEM; return -ENOMEM;
if ((err = read_log(log))) if ((err = read_log(log)))
return err; goto out_free;
/* now register seq file */ /* now register seq file */
err = seq_open(file, &tpm_ascii_b_measurments_seqops); err = seq_open(file, &tpm_ascii_b_measurments_seqops);
...@@ -435,10 +435,15 @@ static int tpm_ascii_bios_measurements_open(struct inode *inode, ...@@ -435,10 +435,15 @@ static int tpm_ascii_bios_measurements_open(struct inode *inode,
seq = file->private_data; seq = file->private_data;
seq->private = log; seq->private = log;
} else { } else {
kfree(log->bios_event_log); goto out_free;
kfree(log);
} }
out:
return err; return err;
out_free:
kfree(log->bios_event_log);
kfree(log);
goto out;
} }
const struct file_operations tpm_ascii_bios_measurements_ops = { const struct file_operations tpm_ascii_bios_measurements_ops = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment