[<prev] [next>] [day] [month] [year] [list]
Message-Id: <200707190111.55097.jesper.juhl@gmail.com>
Date: Thu, 19 Jul 2007 01:11:54 +0200
From: Jesper Juhl <jesper.juhl@...il.com>
To: Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Cc: Seiji Munetoh <munetoh@...ibm.com>,
Stefan Berger <stefanb@...ibm.com>,
Reiner Sailer <sailer@...son.ibm.com>,
Kylene Hall <kjhall@...ibm.com>, jesper.juhl@...il.com
Subject: [PATCH] Memory leak in tpm_ascii_bios_measurements_open() fix.
Ehlo,
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'.
This patch should fix it, but please double check it. I don't know
this code very well and the patch has only been compile tested.
Signed-off-by: Jesper Juhl <jesper.juhl@...il.com>
---
drivers/char/tpm/tpm_bios.c | 11 ++++++++---
1 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/drivers/char/tpm/tpm_bios.c b/drivers/char/tpm/tpm_bios.c
index 4eba32b..4b26ce4 100644
--- a/drivers/char/tpm/tpm_bios.c
+++ b/drivers/char/tpm/tpm_bios.c
@@ -427,7 +427,7 @@ 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);
@@ -435,10 +435,15 @@ static int tpm_ascii_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_ascii_bios_measurements_ops = {
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists