Skip to content

Commit

Permalink
Memory leak in tpm_ascii_bios_measurements_open()
Browse files Browse the repository at this point in the history
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: Jesper 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: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Jesper Juhl authored and Linus Torvalds committed Jul 20, 2007
1 parent 22982a5 commit 178554a
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions drivers/char/tpm/tpm_bios.c
Original file line number Diff line number Diff line change
Expand Up @@ -427,18 +427,23 @@ static int tpm_ascii_bios_measurements_open(struct inode *inode,
return -ENOMEM;

if ((err = read_log(log)))
return err;
goto out_free;

/* now register seq file */
err = seq_open(file, &tpm_ascii_b_measurments_seqops);
if (!err) {
seq = file->private_data;
seq->private = log;
} else {
kfree(log->bios_event_log);
kfree(log);
goto out_free;
}

out:
return err;
out_free:
kfree(log->bios_event_log);
kfree(log);
goto out;
}

const struct file_operations tpm_ascii_bios_measurements_ops = {
Expand Down

0 comments on commit 178554a

Please sign in to comment.