Skip to content

Commit 178554a

Browse files
Jesper JuhlLinus Torvalds
authored andcommitted
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: 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>
1 parent 22982a5 commit 178554a

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

‎drivers/char/tpm/tpm_bios.c‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -427,18 +427,23 @@ static int tpm_ascii_bios_measurements_open(struct inode *inode,
427427
return -ENOMEM;
428428

429429
if ((err = read_log(log)))
430-
return err;
430+
goto out_free;
431431

432432
/* now register seq file */
433433
err = seq_open(file, &tpm_ascii_b_measurments_seqops);
434434
if (!err) {
435435
seq = file->private_data;
436436
seq->private = log;
437437
} else {
438-
kfree(log->bios_event_log);
439-
kfree(log);
438+
goto out_free;
440439
}
440+
441+
out:
441442
return err;
443+
out_free:
444+
kfree(log->bios_event_log);
445+
kfree(log);
446+
goto out;
442447
}
443448

444449
const struct file_operations tpm_ascii_bios_measurements_ops = {

0 commit comments

Comments
 (0)