]> git.baikalelectronics.ru Git - kernel.git/commit
libnvdimm, region, pmem: fix 'badblocks' sysfs_get_dirent() reference lifetime
authorDan Williams <dan.j.williams@intel.com>
Sat, 1 Jul 2017 01:56:03 +0000 (18:56 -0700)
committerDan Williams <dan.j.williams@intel.com>
Sat, 1 Jul 2017 01:56:03 +0000 (18:56 -0700)
commitae63fa39f8ebdb3996f5aca4554b2d1fb860e48a
tree409956203680b40ba7802c576fb02f6fab206245
parentd59b6db4df2412edb549939fe2e217a484448834
libnvdimm, region, pmem: fix 'badblocks' sysfs_get_dirent() reference lifetime

We need to hold a reference on the 'dirent' until we are sure there are
no more notifications that will be sent. As noted in the new comments we
take advantage of the fact that the references are taken and dropped
under device_lock() and that nd_device_notify() holds device_lock() over
new badblocks notifications. The notifications that happen when
badblocks are cleared only occur while the device is active.

Also take the opportunity to fix up the error messages to report the
user visible effect of a sysfs_get_dirent() failure.

Fixes: ac883d258fa6 ("libnvdimm, pmem: Add sysfs notifications to badblocks")
Cc: Toshi Kani <toshi.kani@hpe.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
drivers/nvdimm/pmem.c
drivers/nvdimm/region.c