Hi! Hannes,

Hannes Reinecke <[email protected]> writes:

> Once devm_namespace_enable() has been called the error path in the
> calling function will not call devm_namespace_disable(), leaving the
> namespace enabled on error.
>
> Signed-off-by: Hannes Reinecke <[email protected]>
> ---
>  drivers/dax/pmem/core.c   |  2 +-
>  drivers/nvdimm/btt.c      |  5 ++++-
>  drivers/nvdimm/claim.c    |  8 +++++++-
>  drivers/nvdimm/pfn_devs.c |  1 +
>  drivers/nvdimm/pmem.c     | 20 ++++++++++----------
>  5 files changed, 23 insertions(+), 13 deletions(-)
>

[snip]

> diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c
> index d25e66fd942d..4f667fe6ef72 100644
> --- a/drivers/nvdimm/pmem.c
> +++ b/drivers/nvdimm/pmem.c
> @@ -401,8 +401,10 @@ static int pmem_attach_disk(struct device *dev,
>       if (is_nd_pfn(dev)) {
>               nd_pfn = to_nd_pfn(dev);
>               rc = nvdimm_setup_pfn(nd_pfn, &pmem->pgmap);
> -             if (rc)
> +             if (rc) {
> +                     devm_namespace_disable(dev, ndns);
>                       return rc;
> +             }

As mentioned in the previous mail, when rc != 0, disable is called again
here.

>       }
>  
>       /* we're attaching a block device, disable raw namespace access */
> @@ -549,17 +551,15 @@ static int nd_pmem_probe(struct device *dev)
>       ret = nd_pfn_probe(dev, ndns);
>       if (ret == 0)
>               return -ENXIO;
> -     else if (ret == -EOPNOTSUPP)
> -             return ret;
> -
> -     ret = nd_dax_probe(dev, ndns);
> -     if (ret == 0)
> -             return -ENXIO;
> -     else if (ret == -EOPNOTSUPP)
> -             return ret;
> -
> +     else if (ret != EOPNOTSUPP) {
                        ^ -EOPNOTSUPP

Thanks,
Santosh
> +             ret = nd_dax_probe(dev, ndns);
> +             if (ret == 0)
> +                     return -ENXIO;
> +     }
>       /* probe complete, attach handles namespace enabling */
>       devm_namespace_disable(dev, ndns);
> +     if (ret == -EOPNOTSUPP)
> +             return ret;
>  
>       return pmem_attach_disk(dev, ndns);
>  }
> -- 
> 2.16.4
> _______________________________________________
> Linux-nvdimm mailing list -- [email protected]
> To unsubscribe send an email to [email protected]
_______________________________________________
Linux-nvdimm mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to