public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jarkko Sakkinen <jarkko@kernel.org>
To: Elena Reshetova <elena.reshetova@intel.com>
Cc: dave.hansen@intel.com, seanjc@google.com, kai.huang@intel.com,
	linux-sgx@vger.kernel.org, linux-kernel@vger.kernel.org,
	x86@kernel.org, asit.k.mallick@intel.com,
	vincent.r.scarlata@intel.com, chongc@google.com,
	erdemaktas@google.com, vannapurve@google.com,
	dionnaglaze@google.com, bondarn@google.com,
	scott.raynor@intel.com
Subject: Re: [PATCH v4 1/1] x86/sgx: Enable automatic SVN updates for SGX enclaves
Date: Thu, 8 May 2025 23:13:24 +0300	[thread overview]
Message-ID: <aB0QZP4Mi4hydNSx@kernel.org> (raw)
In-Reply-To: <20250507111542.709858-2-elena.reshetova@intel.com>

On Wed, May 07, 2025 at 02:14:00PM +0300, Elena Reshetova wrote:
  
> diff --git a/arch/x86/kernel/cpu/sgx/driver.c b/arch/x86/kernel/cpu/sgx/driver.c
> index 7f8d1e11dbee..669e44d61f9f 100644
> --- a/arch/x86/kernel/cpu/sgx/driver.c
> +++ b/arch/x86/kernel/cpu/sgx/driver.c
> @@ -19,6 +19,10 @@ static int sgx_open(struct inode *inode, struct file *file)
>  	struct sgx_encl *encl;
>  	int ret;
>  
> +	ret = sgx_inc_usage_count();
> +	if (ret)
> +		return ret;
> +
>  	encl = kzalloc(sizeof(*encl), GFP_KERNEL);
>  	if (!encl)
>  		return -ENOMEM;

The rollback looks broken to me.

Let's clean up error handling a bit:

	encl = kzalloc(sizeof(*encl), GFP_KERNEL);
	if (!encl) {
		ret = -ENOMEM;
		goto err_usage_count;
	}

And later on in the same function:

	ret = init_srcu_struct(&encl->srcu);
	if (ret)
		goto err_encl;

And finally tail:

	return 0;

err_encl:
	kfree(encl);

err_usage_count:
	sgx_dec_usage_count();
	return ret;
}

BR, Jarkko

  parent reply	other threads:[~2025-05-08 20:13 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-07 11:13 [PATCH v4 0/1] Enable automatic SVN updates for SGX enclaves Elena Reshetova
2025-05-07 11:14 ` [PATCH v4 1/1] x86/sgx: " Elena Reshetova
2025-05-07 16:04   ` Dave Hansen
2025-05-08 14:07     ` Reshetova, Elena
2025-05-08 15:45       ` Dave Hansen
2025-05-12 12:54         ` Reshetova, Elena
2025-05-14  7:32           ` Reshetova, Elena
2025-05-15 15:37             ` Dave Hansen
2025-05-08 20:13   ` Jarkko Sakkinen [this message]
2025-05-12 13:54     ` Reshetova, Elena

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=aB0QZP4Mi4hydNSx@kernel.org \
    --to=jarkko@kernel.org \
    --cc=asit.k.mallick@intel.com \
    --cc=bondarn@google.com \
    --cc=chongc@google.com \
    --cc=dave.hansen@intel.com \
    --cc=dionnaglaze@google.com \
    --cc=elena.reshetova@intel.com \
    --cc=erdemaktas@google.com \
    --cc=kai.huang@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sgx@vger.kernel.org \
    --cc=scott.raynor@intel.com \
    --cc=seanjc@google.com \
    --cc=vannapurve@google.com \
    --cc=vincent.r.scarlata@intel.com \
    --cc=x86@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