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

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;
+
 	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;
-- 
2.30.2


  reply	other threads:[~2024-07-15 11:23 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 ` lukas.funke-oss [this message]
2024-07-17  7:39   ` [PATCH 1/1] tpm: call tpm_tis_wait_init() after tpm_tis_init() Miquel Raynal
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=20240715112302.652527-2-lukas.funke-oss@weidmueller.com \
    --to=lukas.funke-oss@weidmueller.com \
    --cc=ilias.apalodimas@linaro.org \
    --cc=lukas.funke@weidmueller.com \
    --cc=miquel.raynal@bootlin.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 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.