public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jarkko Sakkinen <jarkko@kernel.org>
To: linux-integrity@vger.kernel.org
Cc: James.Bottomley@HansenPartnership.com, roberto.sassu@huawei.com,
	mapengyu@gmail.com, Jarkko Sakkinen <jarkko@kernel.org>,
	Peter Huewe <peterhuewe@gmx.de>, Jason Gunthorpe <jgg@ziepe.ca>,
	linux-kernel@vger.kernel.org (open list)
Subject: [PATCH 2/4] tpm: address tpm2_create_null_primary() return value
Date: Sun, 15 Sep 2024 21:04:44 +0300	[thread overview]
Message-ID: <20240915180448.2030115-3-jarkko@kernel.org> (raw)
In-Reply-To: <20240915180448.2030115-1-jarkko@kernel.org>

tpm2_sessions_init() does not check the return value of
tpm2_create_null_primary(). Return on failure.

Fixes: d2add27cf2b8 ("tpm: Add NULL primary creation")
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
---
 drivers/char/tpm/tpm2-sessions.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/char/tpm/tpm2-sessions.c b/drivers/char/tpm/tpm2-sessions.c
index 6cc1ea81c57c..d63510ad44ab 100644
--- a/drivers/char/tpm/tpm2-sessions.c
+++ b/drivers/char/tpm/tpm2-sessions.c
@@ -1288,8 +1288,10 @@ int tpm2_sessions_init(struct tpm_chip *chip)
 	int rc;
 
 	rc = tpm2_create_null_primary(chip);
-	if (rc)
+	if (rc) {
 		dev_err(&chip->dev, "TPM: security failed (NULL seed derivation): %d\n", rc);
+		return rc;
+	}
 
 	chip->auth = kmalloc(sizeof(*chip->auth), GFP_KERNEL);
 	if (!chip->auth)
-- 
2.46.0


  parent reply	other threads:[~2024-09-15 18:05 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-15 18:04 [PATCH 0/4] tpm: lazy flush for the session null key Jarkko Sakkinen
2024-09-15 18:04 ` [PATCH 1/4] tpm: remove file header documentation from tpm2-sessions.c Jarkko Sakkinen
2024-09-15 18:04 ` Jarkko Sakkinen [this message]
2024-09-15 18:04 ` [PATCH 3/4] tpm: address tpm2_create_primary() failure Jarkko Sakkinen
2024-09-15 18:04 ` [PATCH 4/4] tpm: flush the session null key only when required Jarkko Sakkinen
2024-09-15 18:12 ` [PATCH 0/4] tpm: lazy flush for the session null key Jarkko Sakkinen
     [not found] ` <CALSz7m0ehXM+dU3z0xYPLQkHbyfyMjoCOoMLdBgRcUu1pnT_ww@mail.gmail.com>
2024-09-16  2:33   ` Pengyu Ma
2024-09-16  5:16     ` Jarkko Sakkinen
2024-09-16  5:53       ` Pengyu Ma

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=20240915180448.2030115-3-jarkko@kernel.org \
    --to=jarkko@kernel.org \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=jgg@ziepe.ca \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mapengyu@gmail.com \
    --cc=peterhuewe@gmx.de \
    --cc=roberto.sassu@huawei.com \
    /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