linux-integrity.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Berger <stefanb@linux.ibm.com>
To: linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org,
	jarkko@kernel.org
Cc: Stefan Berger <stefanb@linux.ibm.com>
Subject: [PATCH] tpm: Check for availability of chip->ops before requesting locality
Date: Wed,  7 Jun 2023 12:16:47 -0400	[thread overview]
Message-ID: <20230607161647.3257117-1-stefanb@linux.ibm.com> (raw)

When executing kexec on ppc64 tpm_class_shutdown() is called before
tpm_chip_unregister() and therefore chip->ops is NULL when
tpm_amd_is_rng_defective() is called. Check for chip->ops before
requesting the locality in tpm_amd_is_rng_defective() to avoid a
crash.

Fixes: bd8621ca1510 ("tpm: Add !tpm_amd_is_rng_defective() to the hwrng_unregister() call site")
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
---
 drivers/char/tpm/tpm-chip.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c
index cd48033b804a..bc1ec1632fd8 100644
--- a/drivers/char/tpm/tpm-chip.c
+++ b/drivers/char/tpm/tpm-chip.c
@@ -524,7 +524,7 @@ static bool tpm_amd_is_rng_defective(struct tpm_chip *chip)
 	u64 version;
 	int ret;
 
-	if (!(chip->flags & TPM_CHIP_FLAG_TPM2))
+	if (!chip->ops || !(chip->flags & TPM_CHIP_FLAG_TPM2))
 		return false;
 
 	ret = tpm_request_locality(chip);
-- 
2.39.1


                 reply	other threads:[~2023-06-07 16:17 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20230607161647.3257117-1-stefanb@linux.ibm.com \
    --to=stefanb@linux.ibm.com \
    --cc=jarkko@kernel.org \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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).