Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1254371

Re: [PATCH] TPM: Avoid reference to potentially freed memory

From Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Newsgroups linux.kernel
Subject Re: [PATCH] TPM: Avoid reference to potentially freed memory
Date 2015-10-23 09:40 +0200
Message-ID <qmF7b-351-5@gated-at.bofh.it> (permalink)
References <qmuOu-537-7@gated-at.bofh.it>
Organization Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo

Show all headers | View raw


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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] TPM: Avoid reference to potentially freed memory Christophe JAILLET <christophe.jaillet@wanadoo.fr> - 2015-10-22 22:40 +0200
  Re: [PATCH] TPM: Avoid reference to potentially freed memory Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> - 2015-10-23 09:40 +0200
    Re: [tpmdd-devel] [PATCH] TPM: Avoid reference to potentially freed  memory Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> - 2015-10-27 11:30 +0100
      Re: [tpmdd-devel] [PATCH] TPM: Avoid reference to potentially freed  memory Marion & Christophe JAILLET <christophe.jaillet@wanadoo.fr> - 2015-10-29 07:20 +0100
        Re: [tpmdd-devel] [PATCH] TPM: Avoid reference to potentially freed  memory Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> - 2015-10-29 11:50 +0100
          Re: [tpmdd-devel] [PATCH] TPM: Avoid reference to potentially freed  memory Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> - 2015-10-30 12:40 +0100

csiph-web