From: Gregory Price <gourry@gourry.net>
To: Ira Weiny <ira.weiny@intel.com>
Cc: linux-cxl@vger.kernel.org, linux-kernel@vger.kernel.org,
kernel-team@meta.com, dave@stgolabs.net,
jonathan.cameron@huawei.com, dave.jiang@intel.com,
alison.schofield@intel.com, vishal.l.verma@intel.com,
dan.j.williams@intel.com
Subject: Re: [PATCH] cxl/memdev: fix deadlock in cxl_memdev_autoremove() on attach failure
Date: Tue, 10 Feb 2026 17:46:11 -0500 [thread overview]
Message-ID: <aYu1M75-tV8-TLAC@gourry-fedora-PF4VCD3F> (raw)
In-Reply-To: <698b8a8620f2a_dce1110074@iweiny-mobl.notmuch>
On Tue, Feb 10, 2026 at 01:44:06PM -0600, Ira Weiny wrote:
> Gregory Price wrote:
> >
> > diff --git a/drivers/cxl/core/memdev.c b/drivers/cxl/core/memdev.c
> > index af3d0cc65138..c0de767b24fb 100644
> > --- a/drivers/cxl/core/memdev.c
> > +++ b/drivers/cxl/core/memdev.c
> > @@ -1098,19 +1098,22 @@ static struct cxl_memdev *cxl_memdev_autoremove(struct cxl_memdev *cxlmd)
> > * return. Note that failure here could be the result of a race to
> > * teardown the CXL port topology. I.e. cxl_mem_probe() could have
> > * succeeded and then cxl_mem unbound before the lock is acquired.
> > + *
> > + * Check under device_lock but unregister outside of it, as
> > + * cxl_memdev_unregister() will also take the device lock.
> > */
> > - guard(device)(&cxlmd->dev);
> > - if (cxlmd->attach && !cxlmd->dev.driver) {
> > - cxl_memdev_unregister(cxlmd);
> > - return ERR_PTR(-ENXIO);
> > + scoped_guard(device, &cxlmd->dev) {
> > + if (cxlmd->attach && !cxlmd->dev.driver)
> > + break;
> > +
> > + rc = devm_add_action_or_reset(cxlmd->cxlds->dev,
> > + cxl_memdev_unregister, cxlmd);
>
> This kind of threw me... Won't this deadlock if
> devm_add_action_or_reset() fails as well?
>
> Need to use devm_add_action() and drop out of the guard on failure.
>
lol i pointed out that this patch was a claude recommendation on the
initial report - didn't look to hard because it fixed this specific
deadlock with:
if (cxlmd->attach && !cxlmd->dev.driver)
break;
so yeah, easy enough to fixup.
I can either v2 or Dave if you want to just make the oneline change
before pull let me know
~Gregory
next prev parent reply other threads:[~2026-02-10 22:46 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-10 15:43 [PATCH] cxl/memdev: fix deadlock in cxl_memdev_autoremove() on attach failure Gregory Price
2026-02-10 16:27 ` Dave Jiang
2026-02-10 19:44 ` Ira Weiny
2026-02-10 22:46 ` Gregory Price [this message]
2026-02-10 23:20 ` Dave Jiang
2026-02-11 0:05 ` Gregory Price
2026-02-10 23:18 ` dan.j.williams
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=aYu1M75-tV8-TLAC@gourry-fedora-PF4VCD3F \
--to=gourry@gourry.net \
--cc=alison.schofield@intel.com \
--cc=dan.j.williams@intel.com \
--cc=dave.jiang@intel.com \
--cc=dave@stgolabs.net \
--cc=ira.weiny@intel.com \
--cc=jonathan.cameron@huawei.com \
--cc=kernel-team@meta.com \
--cc=linux-cxl@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=vishal.l.verma@intel.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