diff options
author | Dan Williams <dan.j.williams@intel.com> | 2018-09-27 18:01:55 -0400 |
---|---|---|
committer | Dan Williams <dan.j.williams@intel.com> | 2018-09-28 14:12:34 -0400 |
commit | 5d394eee2c102453278d81d9a7cf94c80253486a (patch) | |
tree | 13aa5100525edf5f662942f4ecb34bcf4a8d93ef | |
parent | 48af2f7e52f4cd5eb41ebcd1bd2e326aa2d33d32 (diff) |
libnvdimm, region: Fail badblocks listing for inactive regions
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>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
-rw-r--r-- | drivers/nvdimm/region_devs.c | 11 |
1 files 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, | |||
560 | struct device_attribute *attr, char *buf) | 560 | struct device_attribute *attr, char *buf) |
561 | { | 561 | { |
562 | struct nd_region *nd_region = to_nd_region(dev); | 562 | struct nd_region *nd_region = to_nd_region(dev); |
563 | ssize_t rc; | ||
563 | 564 | ||
564 | return badblocks_show(&nd_region->bb, buf, 0); | 565 | device_lock(dev); |
565 | } | 566 | if (dev->driver) |
567 | rc = badblocks_show(&nd_region->bb, buf, 0); | ||
568 | else | ||
569 | rc = -ENXIO; | ||
570 | device_unlock(dev); | ||
566 | 571 | ||
572 | return rc; | ||
573 | } | ||
567 | static DEVICE_ATTR(badblocks, 0444, region_badblocks_show, NULL); | 574 | static DEVICE_ATTR(badblocks, 0444, region_badblocks_show, NULL); |
568 | 575 | ||
569 | static ssize_t resource_show(struct device *dev, | 576 | static ssize_t resource_show(struct device *dev, |