nvdimm.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH] libnvdimm, region: Fail badblocks listing for inactive regions
@ 2018-09-28 18:04 Dan Williams
  2018-09-28 18:47 ` Dave Jiang
  2018-10-01 12:11 ` Johannes Thumshirn
  0 siblings, 2 replies; 3+ messages in thread
From: Dan Williams @ 2018-09-28 18:04 UTC (permalink / raw)
  To: linux-nvdimm; +Cc: linux-kernel, stable

While experimenting with region driver loading the following backtrace
was triggered:

 INFO: trying to register non-static key.
 the code is fine but needs lockdep annotation.
 turning off the locking correctness validator.
 [..]
 Call Trace:
  dump_stack+0x85/0xcb
  register_lock_class+0x571/0x580
  ? __lock_acquire+0x2ba/0x1310
  ? kernfs_seq_start+0x2a/0x80
  __lock_acquire+0xd4/0x1310
  ? dev_attr_show+0x1c/0x50
  ? __lock_acquire+0x2ba/0x1310
  ? kernfs_seq_start+0x2a/0x80
  ? lock_acquire+0x9e/0x1a0
  lock_acquire+0x9e/0x1a0
  ? dev_attr_show+0x1c/0x50
  badblocks_show+0x70/0x190
  ? dev_attr_show+0x1c/0x50
  dev_attr_show+0x1c/0x50

This results from a missing successful call to devm_init_badblocks()
from nd_region_probe(). Block attempts to show badblocks while the
region is not enabled.

Fixes: 6a6bef90425e ("libnvdimm: add mechanism to publish badblocks...")
Cc: <stable@vger.kernel.org>
Cc: Dave Jiang <dave.jiang@intel.com>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 drivers/nvdimm/region_devs.c |   11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/nvdimm/region_devs.c b/drivers/nvdimm/region_devs.c
index fa37afcd43ff..174a418cb171 100644
--- a/drivers/nvdimm/region_devs.c
+++ b/drivers/nvdimm/region_devs.c
@@ -560,10 +560,17 @@ static ssize_t region_badblocks_show(struct device *dev,
 		struct device_attribute *attr, char *buf)
 {
 	struct nd_region *nd_region = to_nd_region(dev);
+	ssize_t rc;
 
-	return badblocks_show(&nd_region->bb, buf, 0);
-}
+	device_lock(dev);
+	if (dev->driver)
+		rc = badblocks_show(&nd_region->bb, buf, 0);
+	else
+		rc = -ENXIO;
+	device_unlock(dev);
 
+	return rc;
+}
 static DEVICE_ATTR(badblocks, 0444, region_badblocks_show, NULL);
 
 static ssize_t resource_show(struct device *dev,

_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] libnvdimm, region: Fail badblocks listing for inactive regions
  2018-09-28 18:04 [PATCH] libnvdimm, region: Fail badblocks listing for inactive regions Dan Williams
@ 2018-09-28 18:47 ` Dave Jiang
  2018-10-01 12:11 ` Johannes Thumshirn
  1 sibling, 0 replies; 3+ messages in thread
From: Dave Jiang @ 2018-09-28 18:47 UTC (permalink / raw)
  To: Dan Williams, linux-nvdimm; +Cc: linux-kernel, stable



On 09/28/2018 11:04 AM, Dan Williams wrote:
> While experimenting with region driver loading the following backtrace
> was triggered:
> 
>  INFO: trying to register non-static key.
>  the code is fine but needs lockdep annotation.
>  turning off the locking correctness validator.
>  [..]
>  Call Trace:
>   dump_stack+0x85/0xcb
>   register_lock_class+0x571/0x580
>   ? __lock_acquire+0x2ba/0x1310
>   ? kernfs_seq_start+0x2a/0x80
>   __lock_acquire+0xd4/0x1310
>   ? dev_attr_show+0x1c/0x50
>   ? __lock_acquire+0x2ba/0x1310
>   ? kernfs_seq_start+0x2a/0x80
>   ? lock_acquire+0x9e/0x1a0
>   lock_acquire+0x9e/0x1a0
>   ? dev_attr_show+0x1c/0x50
>   badblocks_show+0x70/0x190
>   ? dev_attr_show+0x1c/0x50
>   dev_attr_show+0x1c/0x50
> 
> This results from a missing successful call to devm_init_badblocks()
> from nd_region_probe(). Block attempts to show badblocks while the
> region is not enabled.
> 
> Fixes: 6a6bef90425e ("libnvdimm: add mechanism to publish badblocks...")
> Cc: <stable@vger.kernel.org>
> Cc: Dave Jiang <dave.jiang@intel.com>
> Cc: Johannes Thumshirn <jthumshirn@suse.de>
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>

Reviewed-by: Dave Jiang <dave.jiang@intel.com>

> ---
>  drivers/nvdimm/region_devs.c |   11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/nvdimm/region_devs.c b/drivers/nvdimm/region_devs.c
> index fa37afcd43ff..174a418cb171 100644
> --- a/drivers/nvdimm/region_devs.c
> +++ b/drivers/nvdimm/region_devs.c
> @@ -560,10 +560,17 @@ static ssize_t region_badblocks_show(struct device *dev,
>  		struct device_attribute *attr, char *buf)
>  {
>  	struct nd_region *nd_region = to_nd_region(dev);
> +	ssize_t rc;
>  
> -	return badblocks_show(&nd_region->bb, buf, 0);
> -}
> +	device_lock(dev);
> +	if (dev->driver)
> +		rc = badblocks_show(&nd_region->bb, buf, 0);
> +	else
> +		rc = -ENXIO;
> +	device_unlock(dev);
>  
> +	return rc;
> +}
>  static DEVICE_ATTR(badblocks, 0444, region_badblocks_show, NULL);
>  
>  static ssize_t resource_show(struct device *dev,
> 
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] libnvdimm, region: Fail badblocks listing for inactive regions
  2018-09-28 18:04 [PATCH] libnvdimm, region: Fail badblocks listing for inactive regions Dan Williams
  2018-09-28 18:47 ` Dave Jiang
@ 2018-10-01 12:11 ` Johannes Thumshirn
  1 sibling, 0 replies; 3+ messages in thread
From: Johannes Thumshirn @ 2018-10-01 12:11 UTC (permalink / raw)
  To: Dan Williams; +Cc: linux-kernel, stable, linux-nvdimm

Looks good,
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
-- 
Johannes Thumshirn                                          Storage
jthumshirn@suse.de                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-10-01 12:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-28 18:04 [PATCH] libnvdimm, region: Fail badblocks listing for inactive regions Dan Williams
2018-09-28 18:47 ` Dave Jiang
2018-10-01 12:11 ` Johannes Thumshirn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).