Commit ecfb6d8a authored by Dan Williams's avatar Dan Williams

libnvdimm: fix devm_nvdimm_memremap() error path

The internal alloc_nvdimm_map() helper might fail, particularly if the
memory region is already busy.  Report request_mem_region() failures and
check for the failure.
Reported-by: default avatarRyan Chen <ryan.chan105@gmail.com>
Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
parent 9d15ce9c
......@@ -99,8 +99,11 @@ static struct nvdimm_map *alloc_nvdimm_map(struct device *dev,
nvdimm_map->size = size;
kref_init(&nvdimm_map->kref);
if (!request_mem_region(offset, size, dev_name(&nvdimm_bus->dev)))
if (!request_mem_region(offset, size, dev_name(&nvdimm_bus->dev))) {
dev_err(&nvdimm_bus->dev, "failed to request %pa + %zd for %s\n",
&offset, size, dev_name(dev));
goto err_request_region;
}
if (flags)
nvdimm_map->mem = memremap(offset, size, flags);
......@@ -171,6 +174,9 @@ void *devm_nvdimm_memremap(struct device *dev, resource_size_t offset,
kref_get(&nvdimm_map->kref);
nvdimm_bus_unlock(dev);
if (!nvdimm_map)
return NULL;
if (devm_add_action_or_reset(dev, nvdimm_map_put, nvdimm_map))
return NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment