The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Tom Lendacky <thomas.lendacky@amd.com>
To: Dan Carpenter <dan.carpenter@linaro.org>,
	Alexey Kardashevskiy <aik@amd.com>
Cc: Ashish Kalra <ashish.kalra@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: Re: [PATCH next] crypto/ccp: sev-dev-tsm: fix use after free in sev_tsm_init_locked()
Date: Tue, 9 Dec 2025 11:05:04 -0600	[thread overview]
Message-ID: <78425800-35f4-4455-8d85-fda6bc8fcded@amd.com> (raw)
In-Reply-To: <aTLEVmFVGWn-Czkc@stanley.mountain>

On 12/5/25 05:39, Dan Carpenter wrote:
> 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>

Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>

> ---
>  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)


      reply	other threads:[~2025-12-09 17:05 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-05 11:39 [PATCH next] crypto/ccp: sev-dev-tsm: fix use after free in sev_tsm_init_locked() Dan Carpenter
2025-12-09 17:05 ` Tom Lendacky [this message]

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=78425800-35f4-4455-8d85-fda6bc8fcded@amd.com \
    --to=thomas.lendacky@amd.com \
    --cc=aik@amd.com \
    --cc=ashish.kalra@amd.com \
    --cc=dan.carpenter@linaro.org \
    --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 \
    /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