On Fri, Oct 30, 2026 at 08:11:12PM +0200, Avi Weiss wrote:
> nd_pmem_probe() ignores errors from nd_btt_probe() and only propagates
> -EOPNOTSUPP from nd_pfn_probe() and nd_dax_probe(). An allocation
> failure such as -ENOMEM can therefore be overwritten by subsequent
> personality probes, allowing the namespace to be attached as raw PMEM.
> 
> Return discovery errors other than -ENODEV and -ENXIO. Preserve the
> existing raw-PMEM fallback for those error codes.
> 
> Fixes: 8c2f7e8658df ("libnvdimm: infrastructure for btt devices")
> Signed-off-by: Avi Weiss <[email protected]>
> ---
>  drivers/nvdimm/pmem.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c
> index 0766a6949b28..78acc9b0b1a0 100644
> --- a/drivers/nvdimm/pmem.c
> +++ b/drivers/nvdimm/pmem.c
> @@ -632,6 +632,8 @@ static int nd_pmem_probe(struct device *dev)
>       ret = nd_btt_probe(dev, ndns);
>       if (ret == 0)
>               return -ENXIO;
> +     else if (ret != -ENODEV && ret != -ENXIO)
> +             return ret;

Hi Avi,

Thanks for the patch! I think it could be made more complete.

Does this also need changes in the discovery helpers? If the btt_sb
allocation fails, __nd_btt_probe() returns -ENODEV, so this still allows
fallback to raw PMEM.

The pfn_sb allocations in nd_pfn_probe() and nd_dax_probe() appear to have
the same issue: nd_pfn_validate() returns -ENODEV for a NULL buffer.
Should those allocation failures return -ENOMEM too?


>  
>       /*
>        * We have two failure conditions here, there is no
> @@ -647,13 +649,13 @@ static int nd_pmem_probe(struct device *dev)
>       ret = nd_pfn_probe(dev, ndns);
>       if (ret == 0)
>               return -ENXIO;
> -     else if (ret == -EOPNOTSUPP)
> +     else if (ret != -ENODEV && ret != -ENXIO)
>               return ret;
>  
>       ret = nd_dax_probe(dev, ndns);
>       if (ret == 0)
>               return -ENXIO;
> -     else if (ret == -EOPNOTSUPP)
> +     else if (ret != -ENODEV && ret != -ENXIO)
>               return ret;


Suggest updating the comment above nd_pfn_probe()? It says failure
to initialize the pfn superblock advances the namespace seed, but
nvdimm_bus_probe() only does that for success or -EOPNOTSUPP. With other
errors now propagated, that wording seems too broad.

>  
>       /* probe complete, attach handles namespace enabling */
> 
> base-commit: d89e1d186ec9271bf78e62771779e9fc03bf0fc3

Please base your v2 on a linus mainline tag, like v7.4-rc1.

-- Alison



> -- 
> 2.43.0
> 

Reply via email to