U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Miquel Raynal <miquel.raynal@bootlin.com>
To: lukas.funke-oss@weidmueller.com
Cc: u-boot@lists.denx.de, Lukas Funke <lukas.funke@weidmueller.com>,
	Ilias Apalodimas <ilias.apalodimas@linaro.org>,
	Tim Harvey <tharvey@gateworks.com>, Tom Rini <trini@konsulko.com>
Subject: Re: [PATCH 1/1] tpm: call tpm_tis_wait_init() after tpm_tis_init()
Date: Wed, 17 Jul 2024 09:39:01 +0200	[thread overview]
Message-ID: <20240717093901.3d5ee2ed@xps-13> (raw)
In-Reply-To: <20240715112302.652527-2-lukas.funke-oss@weidmueller.com>

Hi Lukas,

lukas.funke-oss@weidmueller.com wrote on Mon, 15 Jul 2024 13:23:01
+0200:

> From: Lukas Funke <lukas.funke@weidmueller.com>
> 
> tpm_tis_wait_init() is using the 'chip->timeout_b' field which is
> initialized in tpm_tis_init(). However, the init-function is called
> *after* tpm_tis_wait_init() introducing an uninitalized field access.
> 
> This commit switches both routines.
> 
> Signed-off-by: Lukas Funke <lukas.funke@weidmueller.com>
> ---
> 
>  drivers/tpm/tpm2_tis_spi.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/tpm/tpm2_tis_spi.c b/drivers/tpm/tpm2_tis_spi.c
> index b0fe97ab1d0..5a4dbfd3ccb 100644
> --- a/drivers/tpm/tpm2_tis_spi.c
> +++ b/drivers/tpm/tpm2_tis_spi.c
> @@ -256,17 +256,17 @@ static int tpm_tis_spi_probe(struct udevice *dev)
>  	/* Ensure a minimum amount of time elapsed since reset of the TPM */
>  	mdelay(drv_data->time_before_first_cmd_ms);
>  
> +	tpm_tis_ops_register(dev, &phy_ops);
> +	ret = tpm_tis_init(dev);
> +	if (ret)
> +		goto err;
> +

Strange, I don't remember wait the init was done after the wait_init,
but at a first glance the fix looks fine.

Acked-by: Miquel Raynal <miquel.raynal@bootlin.com>

>  	ret = tpm_tis_wait_init(dev, chip->locality);
>  	if (ret) {
>  		log(LOGC_DM, LOGL_ERR, "%s: no device found\n", __func__);
>  		return ret;
>  	}
>  
> -	tpm_tis_ops_register(dev, &phy_ops);
> -	ret = tpm_tis_init(dev);
> -	if (ret)
> -		goto err;
> -
>  	priv->pcr_count = drv_data->pcr_count;
>  	priv->pcr_select_min = drv_data->pcr_select_min;
>  	priv->version = TPM_V2;


Thanks,
Miquèl

  reply	other threads:[~2024-07-17  7:39 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-15 11:23 [PATCH 0/1] tpm: fix uninitalized field access lukas.funke-oss
2024-07-15 11:23 ` [PATCH 1/1] tpm: call tpm_tis_wait_init() after tpm_tis_init() lukas.funke-oss
2024-07-17  7:39   ` Miquel Raynal [this message]
2024-07-21 10:08   ` Simon Glass
2024-07-22  7:34     ` Ilias Apalodimas
2024-07-23 12:47       ` Simon Glass
2024-07-23 13:38         ` Ilias Apalodimas

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=20240717093901.3d5ee2ed@xps-13 \
    --to=miquel.raynal@bootlin.com \
    --cc=ilias.apalodimas@linaro.org \
    --cc=lukas.funke-oss@weidmueller.com \
    --cc=lukas.funke@weidmueller.com \
    --cc=tharvey@gateworks.com \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    /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