Fix memory leak in tpm_binary_bios_measurements_open()

The same problem that was fixed for tpm_ascii_bios_measurements_open()
in commit 178554ae75739e91dc4d7c3e42a3db95448cc5bf also occurs in
tpm_binary_bios measurements(). Thanks for noticing this Satyam!

I tested the attached patch to fix tpm_binary_bios_measurments as well.

Signed-off-by: Reiner Sailer <sailer@watson.ibm.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Reiner Sailer and committed by
Linus Torvalds
03ce1104 c1158e63

+8 -3
+8 -3
drivers/char/tpm/tpm_bios.c
··· 465 return -ENOMEM; 466 467 if ((err = read_log(log))) 468 - return err; 469 470 /* now register seq file */ 471 err = seq_open(file, &tpm_binary_b_measurments_seqops); ··· 473 seq = file->private_data; 474 seq->private = log; 475 } else { 476 - kfree(log->bios_event_log); 477 - kfree(log); 478 } 479 return err; 480 } 481 482 const struct file_operations tpm_binary_bios_measurements_ops = {
··· 465 return -ENOMEM; 466 467 if ((err = read_log(log))) 468 + goto out_free; 469 470 /* now register seq file */ 471 err = seq_open(file, &tpm_binary_b_measurments_seqops); ··· 473 seq = file->private_data; 474 seq->private = log; 475 } else { 476 + goto out_free; 477 } 478 + 479 + out: 480 return err; 481 + out_free: 482 + kfree(log->bios_event_log); 483 + kfree(log); 484 + goto out; 485 } 486 487 const struct file_operations tpm_binary_bios_measurements_ops = {