From: Alison Schofield <alison.schofield@intel.com>
To: Avi Weiss <thnkslprpt@gmail.com>
Cc: Dan Williams <djbw@kernel.org>,
Vishal Verma <vishal.l.verma@intel.com>,
Dave Jiang <dave.jiang@intel.com>, <nvdimm@lists.linux.dev>,
<linux-cxl@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] dax/bus: clear parent drvdata when releasing a region
Date: Wed, 2 Dec 2026 17:54:41 -0800 [thread overview]
Message-ID: <axDL4RgJY33u-1Ok@aschofie-mobl2.lan> (raw)
In-Reply-To: <20261028065000.580077-2-thnkslprpt@gmail.com>
On Wed, Oct 28, 2026 at 08:50:01AM +0200, Avi Weiss wrote:
> alloc_dax_region() sets parent drvdata before reserving the resource
> and registering sysfs attributes. If either operation fails, the
> region is freed but drvdata still points to it. A later allocation
> on the same parent is rejected by the non-NULL drvdata check.
>
> The devres unregister action also leaves drvdata pointing to the
> released region. Clear drvdata on both allocation error and
> unregister paths.
Hi Avi,
Thanks for the patch!
I'm not finding a way to reach a second alloc_dax_region() call with stale
drvdata? The PMEM, HMEM, and CXL callers all fail probe if allocation fails,
and the driver core clears drvdata before the next probe. On unbind, the
driver core also clears it after releasing devres.
If there’s a path where the stale pointer causes a failure, please describe
it in the commit message. Otherwise, please drop the reprobe claim and the
Fixes: tag and describe the change as clearing the parent’s drvdata before
dropping the region reference.
The code changes look fine as written.
-- Alison
>
> Fixes: d7fe1a67f658 ("dax: add region 'id', 'size', and 'align' attributes")
> Signed-off-by: Avi Weiss <thnkslprpt@gmail.com>
> ---
> drivers/dax/bus.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/dax/bus.c b/drivers/dax/bus.c
> index b809e1a264afa..dceaa395760e7 100644
> --- a/drivers/dax/bus.c
> +++ b/drivers/dax/bus.c
> @@ -627,6 +627,7 @@ static void dax_region_unregister(void *region)
> sysfs_remove_groups(&dax_region->dev->kobj,
> dax_region_attribute_groups);
> release_resource(&dax_region->res);
> + dev_set_drvdata(dax_region->dev, NULL);
> dax_region_put(dax_region);
> }
>
> @@ -685,6 +686,7 @@ struct dax_region *alloc_dax_region(struct device *parent, int region_id,
> err_sysfs:
> release_resource(&dax_region->res);
> err_res:
> + dev_set_drvdata(parent, NULL);
> dax_region_put(dax_region);
> return NULL;
> }
>
> base-commit: d135ab453a7400a34930bdda1ef4bdc8acfac80e
> --
> 2.43.0
>
prev parent reply other threads:[~2026-12-03 1:55 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-28 6:50 Avi Weiss
2026-12-03 1:54 ` Alison Schofield [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=axDL4RgJY33u-1Ok@aschofie-mobl2.lan \
--to=alison.schofield@intel.com \
--cc=dave.jiang@intel.com \
--cc=djbw@kernel.org \
--cc=linux-cxl@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nvdimm@lists.linux.dev \
--cc=thnkslprpt@gmail.com \
--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
all inboxes | Powered by JetHome®