[PATCH 1/1] tpm: call tpm_tis_wait_init() after tpm_tis_init()

Miquel Raynal miquel.raynal at bootlin.com
Wed Jul 17 09:39:01 CEST 2024


Hi Lukas,

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

> From: Lukas Funke <lukas.funke at 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 at 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 at 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


More information about the U-Boot mailing list