public inbox for linux-nvdimm@lists.01.org
 help / color / mirror / Atom feed
From: Santosh Sivaraj <santosh@fossix.org>
To: Hannes Reinecke <hare@suse.de>, Dan Williams <dan.williams@intel.com>
Cc: linux-nvdimm@lists.01.org, Hannes Reinecke <hare@suse.de>
Subject: Re: [PATCH] libnvdimm: call devm_namespace_disable() on error
Date: Thu, 09 Jul 2020 11:27:52 +0530	[thread overview]
Message-ID: <87sge1qlgf.fsf@santosiv.in.ibm.com> (raw)
In-Reply-To: <20200703111856.40280-1-hare@suse.de>


Hi! Hannes,

Hannes Reinecke <hare@suse.de> 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 <hare@suse.de>
> ---
>  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 -- linux-nvdimm@lists.01.org
> To unsubscribe send an email to linux-nvdimm-leave@lists.01.org
_______________________________________________
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-leave@lists.01.org

      parent reply	other threads:[~2020-07-09  5:57 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-03 11:18 [PATCH] libnvdimm: call devm_namespace_disable() on error Hannes Reinecke
2020-07-09  5:39 ` Santosh Sivaraj
2020-07-13 14:35   ` Hannes Reinecke
2020-07-09  5:57 ` Santosh Sivaraj [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=87sge1qlgf.fsf@santosiv.in.ibm.com \
    --to=santosh@fossix.org \
    --cc=dan.williams@intel.com \
    --cc=hare@suse.de \
    --cc=linux-nvdimm@lists.01.org \
    /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