All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] TPM: Avoid reference to potentially freed memory
@ 2015-10-22 20:32 ` Christophe JAILLET
  0 siblings, 0 replies; 12+ messages in thread
From: Christophe JAILLET @ 2015-10-22 20:32 UTC (permalink / raw)
  To: peterhuewe, tpmdd, jarkko.sakkinen
  Cc: tpmdd-devel, linux-kernel, kernel-janitors, Christophe JAILLET

Reference to the 'np' node is dropped before dereferencing the 'sizep' and
'basep' pointers, which could by then point to junk if the node has been
freed.

Refactor code to call 'of_node_pup' later.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/char/tpm/tpm_of.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/char/tpm/tpm_of.c b/drivers/char/tpm/tpm_of.c
index 1141456..570f30c 100644
--- a/drivers/char/tpm/tpm_of.c
+++ b/drivers/char/tpm/tpm_of.c
@@ -53,17 +53,18 @@ int read_log(struct tpm_bios_log *log)
 		goto cleanup_eio;
 	}
 
-	of_node_put(np);
 	log->bios_event_log = kmalloc(*sizep, GFP_KERNEL);
 	if (!log->bios_event_log) {
 		pr_err("%s: ERROR - Not enough memory for BIOS measurements\n",
 		       __func__);
+		of_node_put(np);
 		return -ENOMEM;
 	}
 
 	log->bios_event_log_end = log->bios_event_log + *sizep;
 
 	memcpy(log->bios_event_log, __va(*basep), *sizep);
+	of_node_put(np);
 
 	return 0;
 
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2015-10-30 11:38 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-22 20:32 [PATCH] TPM: Avoid reference to potentially freed memory Christophe JAILLET
2015-10-22 20:32 ` Christophe JAILLET
2015-10-23  7:37 ` Jarkko Sakkinen
2015-10-23  7:37   ` Jarkko Sakkinen
2015-10-27 10:27   ` [tpmdd-devel] " Jarkko Sakkinen
2015-10-27 10:27     ` Jarkko Sakkinen
2015-10-29  6:12     ` Marion & Christophe JAILLET
2015-10-29  6:12       ` Marion & Christophe JAILLET
2015-10-29 10:48       ` Jarkko Sakkinen
2015-10-29 10:48         ` Jarkko Sakkinen
2015-10-30 11:38         ` Jarkko Sakkinen
2015-10-30 11:38           ` Jarkko Sakkinen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.