libnvdimm/region: Fix label activation vs errors
There are a few scenarios where init_active_labels() can return without
registering deactivate_labels() to run when the region is disabled. In
particular label error injection creates scenarios where a DIMM is
disabled, but labels on other DIMMs in the region become activated.
Arrange for init_active_labels() to always register deactivate_labels().
Reported-by: Krzysztof Kensicki <krzysztof.kensicki@intel.com>
Cc: <stable@vger.kernel.org>
Fixes: bf9bccc14c
("libnvdimm: pmem label sets and namespace instantiation.")
Reviewed-by: Jeff Moyer <jmoyer@redhat.com>
Link: https://lore.kernel.org/r/162766356450.3223041.1183118139023841447.stgit@dwillia2-desk3.amr.corp.intel.com
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
This commit is contained in:
parent
b93dfa6bda
commit
d9cee9f85b
@ -2527,7 +2527,7 @@ static void deactivate_labels(void *region)
|
|||||||
|
|
||||||
static int init_active_labels(struct nd_region *nd_region)
|
static int init_active_labels(struct nd_region *nd_region)
|
||||||
{
|
{
|
||||||
int i;
|
int i, rc = 0;
|
||||||
|
|
||||||
for (i = 0; i < nd_region->ndr_mappings; i++) {
|
for (i = 0; i < nd_region->ndr_mappings; i++) {
|
||||||
struct nd_mapping *nd_mapping = &nd_region->mapping[i];
|
struct nd_mapping *nd_mapping = &nd_region->mapping[i];
|
||||||
@ -2546,13 +2546,14 @@ static int init_active_labels(struct nd_region *nd_region)
|
|||||||
else if (test_bit(NDD_LABELING, &nvdimm->flags))
|
else if (test_bit(NDD_LABELING, &nvdimm->flags))
|
||||||
/* fail, labels needed to disambiguate dpa */;
|
/* fail, labels needed to disambiguate dpa */;
|
||||||
else
|
else
|
||||||
return 0;
|
continue;
|
||||||
|
|
||||||
dev_err(&nd_region->dev, "%s: is %s, failing probe\n",
|
dev_err(&nd_region->dev, "%s: is %s, failing probe\n",
|
||||||
dev_name(&nd_mapping->nvdimm->dev),
|
dev_name(&nd_mapping->nvdimm->dev),
|
||||||
test_bit(NDD_LOCKED, &nvdimm->flags)
|
test_bit(NDD_LOCKED, &nvdimm->flags)
|
||||||
? "locked" : "disabled");
|
? "locked" : "disabled");
|
||||||
return -ENXIO;
|
rc = -ENXIO;
|
||||||
|
goto out;
|
||||||
}
|
}
|
||||||
nd_mapping->ndd = ndd;
|
nd_mapping->ndd = ndd;
|
||||||
atomic_inc(&nvdimm->busy);
|
atomic_inc(&nvdimm->busy);
|
||||||
@ -2586,13 +2587,17 @@ static int init_active_labels(struct nd_region *nd_region)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i < nd_region->ndr_mappings) {
|
if (i < nd_region->ndr_mappings)
|
||||||
|
rc = -ENOMEM;
|
||||||
|
|
||||||
|
out:
|
||||||
|
if (rc) {
|
||||||
deactivate_labels(nd_region);
|
deactivate_labels(nd_region);
|
||||||
return -ENOMEM;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
return devm_add_action_or_reset(&nd_region->dev, deactivate_labels,
|
return devm_add_action_or_reset(&nd_region->dev, deactivate_labels,
|
||||||
nd_region);
|
nd_region);
|
||||||
}
|
}
|
||||||
|
|
||||||
int nd_region_register_namespaces(struct nd_region *nd_region, int *err)
|
int nd_region_register_namespaces(struct nd_region *nd_region, int *err)
|
||||||
|
Loading…
Reference in New Issue
Block a user