All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dave Hansen <dave.hansen@intel.com>
To: Dingisoul <dingiso.kernel@gmail.com>, linux-sgx@vger.kernel.org
Cc: jarkko@kernel.org, dave.hansen@linux.intel.com, tglx@kernel.org,
	mingo@redhat.com, bp@alien8.de, x86@kernel.org, hpa@zytor.com,
	shuangpeng.kernel@gmail.com
Subject: Re: [BUG] x86/sgx: missing kref_put() in sgx_encl_mm_add() error path
Date: Mon, 30 Mar 2026 14:15:24 -0700	[thread overview]
Message-ID: <6d6fad13-762d-488e-a0b2-86704af64f33@intel.com> (raw)
In-Reply-To: <20260330210957.839878-1-dingiso.kernel@gmail.com>

On 3/30/26 14:09, Dingisoul wrote:
> If __mmu_notifier_register() fails, the function frees encl_mm but
> does not drop the reference acquired by kref_get(&encl->refcount).
> This seems to leak one reference to encl.

Yep it looks like a leak.

> Please let us know if the kref_put is unnecessary here.

The easiest way to fix it is to just move the kref_get() until after the
notifier has been registered. There's no risk of encl going away in this
context, so it doesn't matter when the kref_get() happens as long as it
_does_ happen.

  reply	other threads:[~2026-03-30 21:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-30 21:09 [BUG] x86/sgx: missing kref_put() in sgx_encl_mm_add() error path Dingisoul
2026-03-30 21:15 ` Dave Hansen [this message]
2026-03-30 21:25   ` Dingisoul
2026-04-08  8:58 ` Jarkko Sakkinen

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=6d6fad13-762d-488e-a0b2-86704af64f33@intel.com \
    --to=dave.hansen@intel.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=dingiso.kernel@gmail.com \
    --cc=hpa@zytor.com \
    --cc=jarkko@kernel.org \
    --cc=linux-sgx@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=shuangpeng.kernel@gmail.com \
    --cc=tglx@kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.