From: Dan Carpenter <dan.carpenter@linaro.org>
To: Alexey Kardashevskiy <aik@amd.com>
Cc: Ashish Kalra <ashish.kalra@amd.com>,
Tom Lendacky <thomas.lendacky@amd.com>,
John Allen <john.allen@amd.com>,
Herbert Xu <herbert@gondor.apana.org.au>,
"David S. Miller" <davem@davemloft.net>,
Dan Williams <dan.j.williams@intel.com>,
linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org,
kernel-janitors@vger.kernel.org
Subject: [PATCH next] crypto/ccp: sev-dev-tsm: fix use after free in sev_tsm_init_locked()
Date: Fri, 5 Dec 2025 14:39:02 +0300 [thread overview]
Message-ID: <aTLEVmFVGWn-Czkc@stanley.mountain> (raw)
This code frees "t" and then dereferences it on the next line to
print the error code. Re-order the code to avoid the use after
free.
Fixes: 3532f6154971 ("crypto/ccp: Implement SEV-TIO PCIe IDE (phase1)")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
drivers/crypto/ccp/sev-dev-tsm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/crypto/ccp/sev-dev-tsm.c b/drivers/crypto/ccp/sev-dev-tsm.c
index ea29cd5d0ff9..06e9f0bc153e 100644
--- a/drivers/crypto/ccp/sev-dev-tsm.c
+++ b/drivers/crypto/ccp/sev-dev-tsm.c
@@ -391,9 +391,9 @@ void sev_tsm_init_locked(struct sev_device *sev, void *tio_status_page)
return;
error_exit:
- kfree(t);
pr_err("Failed to enable SEV-TIO: ret=%d en=%d initdone=%d SEV=%d\n",
ret, t->tio_en, t->tio_init_done, boot_cpu_has(X86_FEATURE_SEV));
+ kfree(t);
}
void sev_tsm_uninit(struct sev_device *sev)
--
2.51.0
next reply other threads:[~2025-12-05 11:39 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-05 11:39 Dan Carpenter [this message]
2025-12-09 17:05 ` [PATCH next] crypto/ccp: sev-dev-tsm: fix use after free in sev_tsm_init_locked() Tom Lendacky
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=aTLEVmFVGWn-Czkc@stanley.mountain \
--to=dan.carpenter@linaro.org \
--cc=aik@amd.com \
--cc=ashish.kalra@amd.com \
--cc=dan.j.williams@intel.com \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=john.allen@amd.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=thomas.lendacky@amd.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