From: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: peterhuewe@gmx.de, tpmdd@selhorst.net,
tpmdd-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org,
kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] TPM: Avoid reference to potentially freed memory
Date: Fri, 23 Oct 2015 10:37:33 +0300 [thread overview]
Message-ID: <20151023073733.GA6941@intel.com> (raw)
In-Reply-To: <1445545961-5620-1-git-send-email-christophe.jaillet@wanadoo.fr>
On Thu, Oct 22, 2015 at 10:32:41PM +0200, Christophe JAILLET wrote:
> 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>
LGTM.
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
> ---
> 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
>
/Jarkko
next prev parent reply other threads:[~2015-10-23 7:37 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-22 20:32 [PATCH] TPM: Avoid reference to potentially freed memory Christophe JAILLET
2015-10-23 7:37 ` Jarkko Sakkinen [this message]
2015-10-27 10:27 ` [tpmdd-devel] " Jarkko Sakkinen
2015-10-29 6:12 ` Marion & Christophe JAILLET
2015-10-29 10:48 ` Jarkko Sakkinen
2015-10-30 11:38 ` Jarkko Sakkinen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20151023073733.GA6941@intel.com \
--to=jarkko.sakkinen@linux.intel.com \
--cc=christophe.jaillet@wanadoo.fr \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peterhuewe@gmx.de \
--cc=tpmdd-devel@lists.sourceforge.net \
--cc=tpmdd@selhorst.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).