All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alison Schofield <alison.schofield@intel.com>
To: Jiale Yao <yaojiale02@163.com>
Cc: Vishal Verma <vishal.l.verma@intel.com>,
	Dave Jiang <dave.jiang@intel.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	"Joao Martins" <joao.m.martins@oracle.com>,
	<nvdimm@lists.linux.dev>, <linux-cxl@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, <stable@vger.kernel.org>
Subject: Re: [PATCH] dax/device: defer publishing the dynamic pgmap
Date: Fri, 9 Oct 2026 18:48:40 -0700	[thread overview]
Message-ID: <asmZeDROBmmc-3kz@aschofie-mobl2.lan> (raw)
In-Reply-To: <20260927114736.1113965-1-yaojiale02@163.com>

On Sun, Sep 27, 2026 at 07:47:36PM +0800, Jiale Yao wrote:
> The dynamic device-dax probe path publishes its devm-allocated pgmap
> before several operations that can still fail.  If one of them fails,
> devres frees the pgmap while dev_dax->pgmap remains non-NULL.  A later
> bind then fails the dynamic-dax invariant check and leaves the device
> unusable until its region is recreated.
> 
> Defer assigning dev_dax->pgmap until the final devm action has been
> installed and probe can no longer fail.  A failed probe then never
> publishes the temporary pgmap.
> 
> Fixes: fc65c4eb0b2a ("device-dax: ensure dev_dax->pgmap is valid for dynamic devices")
> Cc: stable@vger.kernel.org
> Signed-off-by: Jiale Yao <yaojiale02@163.com>
> ---
>  drivers/dax/device.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/dax/device.c b/drivers/dax/device.c
> index d0c9b4e03b47..8cd8e05872c3 100644
> --- a/drivers/dax/device.c
> +++ b/drivers/dax/device.c
> @@ -409,7 +409,6 @@ static int dev_dax_probe(struct dev_dax *dev_dax)
>  			return -ENOMEM;
>  
>  		pgmap->nr_range = dev_dax->nr_range;
> -		dev_dax->pgmap = pgmap;
>  
>  		for (i = 0; i < dev_dax->nr_range; i++) {
>  			struct range *range = &dev_dax->ranges[i].range;
> @@ -450,7 +449,13 @@ static int dev_dax_probe(struct dev_dax *dev_dax)
>  		return rc;
>  
>  	run_dax(dax_dev);
> -	return devm_add_action_or_reset(dev, dev_dax_kill, dev_dax);
> +	rc = devm_add_action_or_reset(dev, dev_dax_kill, dev_dax);
> +	if (rc)
> +		return rc;
> +
> +	/* Probe can no longer fail; expose the pgmap via dev_dax. */
> +	dev_dax->pgmap = pgmap;
> +	return 0;
>  }

Hi Jiale,

Please address the NULL ptr dereference issue that Sashiko identified.

Could we instead register the dev_dax_kill cleanup action first, then assign
dev_dax->pgmap, and finally call run_dax()?

That would leave the pgmap unpublished on probe failure while ensuring it is
initialized before the device becomes usable. I believe the existing kill_dev_dax()
already clears the pgmap for dynamic devices during teardown.

It sounds like you may have reproduced this issue already. Can you confirm that
you've tested the fix with a failed probe followed by a successful rebind? It
would also be good to confirm that normal bind/unbind/rebind still works.

-- Alison

>  
>  static struct dax_device_driver device_dax_driver = {
> -- 
> 2.34.1
> 

      parent reply	other threads:[~2026-10-10  1:48 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-27 11:47 [PATCH] dax/device: defer publishing the dynamic pgmap Jiale Yao
2026-09-27 11:58 ` sashiko-bot
2026-09-27 20:05 ` Andrew Morton
2026-09-29 21:45   ` Alison Schofield
2026-09-29 21:55     ` Andrew Morton
2026-10-10  1:48 ` 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=asmZeDROBmmc-3kz@aschofie-mobl2.lan \
    --to=alison.schofield@intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=dave.jiang@intel.com \
    --cc=joao.m.martins@oracle.com \
    --cc=linux-cxl@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nvdimm@lists.linux.dev \
    --cc=stable@vger.kernel.org \
    --cc=vishal.l.verma@intel.com \
    --cc=yaojiale02@163.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 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.