]> err.no Git - linux-2.6/commitdiff
Fix memory leak in tpm_binary_bios_measurements_open()
authorReiner Sailer <sailer@us.ibm.com>
Fri, 20 Jul 2007 14:03:02 +0000 (10:03 -0400)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Fri, 20 Jul 2007 19:00:04 +0000 (12:00 -0700)
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>
drivers/char/tpm/tpm_bios.c

index 4b26ce48189b73368685bb5de4ae53549ed5feda..8677fc6a545eebe543d6ac26846879325e97bde5 100644 (file)
@@ -465,7 +465,7 @@ static int tpm_binary_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_binary_b_measurments_seqops);
@@ -473,10 +473,15 @@ static int tpm_binary_bios_measurements_open(struct inode *inode,
                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_binary_bios_measurements_ops = {