Linux cryptographic layer development
 help / color / mirror / Atom feed
From: Tom Lendacky <thomas.lendacky@amd.com>
To: Michael Roth <michael.roth@amd.com>, linux-crypto@vger.kernel.org
Cc: herbert@gondor.apana.org.au, davem@davemloft.net,
	ackerleytng@google.com, ashish.kalra@amd.com, aik@amd.com,
	seanjc@google.com
Subject: Re: [PATCH v2 3/9] crypto: ccp - Use __free() handlers for sev_ioctl_do_pek_csr() allocations
Date: Mon, 19 Oct 2026 08:33:56 -0500	[thread overview]
Message-ID: <dd27e24f-464c-449d-a940-6b92f4d2fbb5@amd.com> (raw)
In-Reply-To: <20261016041109.1778673-4-michael.roth@amd.com>

On 10/15/26 23:09, Michael Roth wrote:
> Make use of __free() handlers so that the related goto statements can be
> dropped. This is in preparation for switching over to using mutex
> guard()'s.
> 
> Signed-off-by: Michael Roth <michael.roth@amd.com>

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

> ---
>  drivers/crypto/ccp/sev-dev.c | 14 +++++---------
>  1 file changed, 5 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c
> index ed60f3db391c..f6d06242184e 100644
> --- a/drivers/crypto/ccp/sev-dev.c
> +++ b/drivers/crypto/ccp/sev-dev.c
> @@ -1986,7 +1986,7 @@ static int sev_ioctl_do_pek_csr(struct sev_issue_cmd *argp, bool writable)
>  	bool shutdown_required = false;
>  	struct sev_data_pek_csr data;
>  	void __user *input_address;
> -	void *blob = NULL;
> +	void *blob __free(kfree) = NULL;
>  	int ret;
>  
>  	if (!writable)
> @@ -2017,7 +2017,7 @@ static int sev_ioctl_do_pek_csr(struct sev_issue_cmd *argp, bool writable)
>  	if (sev->sev_plat_status.state == SEV_STATE_UNINIT) {
>  		ret = sev_move_to_init_state(argp, &shutdown_required);
>  		if (ret)
> -			goto e_free_blob;
> +			return ret;
>  	}
>  
>  	ret = __sev_do_cmd_locked(SEV_CMD_PEK_CSR, &data, &argp->error);
> @@ -2031,21 +2031,17 @@ static int sev_ioctl_do_pek_csr(struct sev_issue_cmd *argp, bool writable)
>  	 */
>  	input.length = data.len;
>  
> -	if (copy_to_user((void __user *)argp->data, &input, sizeof(input))) {
> -		ret = -EFAULT;
> -		goto e_free_blob;
> -	}
> +	if (copy_to_user((void __user *)argp->data, &input, sizeof(input)))
> +		return -EFAULT;
>  
>  	if (ret || WARN_ON_ONCE(argp->error))
> -		goto e_free_blob;
> +		return ret;
>  
>  	if (blob) {
>  		if (copy_to_user(input_address, blob, input.length))
>  			ret = -EFAULT;
>  	}
>  
> -e_free_blob:
> -	kfree(blob);
>  	return ret;
>  }
>  


  reply	other threads:[~2026-10-19 13:34 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-16  4:09 [PATCH v2 0/9] crypto: ccp - Make sev_cmd_mutex more granular Michael Roth
2026-10-16  4:09 ` [PATCH v2 1/9] crypto: ccp - Shut down SEV firmware before copying to user Michael Roth
2026-10-16  4:09 ` [PATCH v2 2/9] crypto: ccp - Check SNP initialization state after copying user inputs Michael Roth
2026-10-16  4:09 ` [PATCH v2 3/9] crypto: ccp - Use __free() handlers for sev_ioctl_do_pek_csr() allocations Michael Roth
2026-10-19 13:33   ` Tom Lendacky [this message]
2026-10-16  4:09 ` [PATCH v2 4/9] crypto: ccp - Use __free() handlers for sev_ioctl_do_pek_import() allocations Michael Roth
2026-10-19 13:38   ` Tom Lendacky
2026-10-16  4:09 ` [PATCH v2 5/9] crypto: ccp - Use __free() handlers for sev_ioctl_do_pdh_export() allocations Michael Roth
2026-10-19 13:40   ` Tom Lendacky
2026-10-16  4:09 ` [PATCH v2 6/9] crypto: ccp: - Rework sev_ioctl_do_pdh_export() to avoid goto usage Michael Roth
2026-10-19 13:49   ` Tom Lendacky
2026-10-16  4:09 ` [PATCH v2 7/9] crypto: ccp - Make usage of sev_cmd_mutex more granular Michael Roth
2026-10-16  4:09 ` [PATCH v2 8/9] crypto: ccp - Use __free() handlers for __sev_do_snp_platform_status() allocations Michael Roth
2026-10-19 14:03   ` Tom Lendacky
2026-10-16  4:09 ` [PATCH v2 9/9] crypto: ccp - Allocate status page outside sev_cmd_mutex in SNP_PLATFORM_STATUS Michael Roth
2026-10-19 14:05   ` Tom Lendacky
2026-10-20 21:42 ` [PATCH v2 0/9] crypto: ccp - Make sev_cmd_mutex more granular Michael Roth
2026-10-21  5:26   ` Herbert Xu

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=dd27e24f-464c-449d-a940-6b92f4d2fbb5@amd.com \
    --to=thomas.lendacky@amd.com \
    --cc=ackerleytng@google.com \
    --cc=aik@amd.com \
    --cc=ashish.kalra@amd.com \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=michael.roth@amd.com \
    --cc=seanjc@google.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