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: Ryan Chen <ryan.chan105@gmail.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
This commit is contained in:
parent
9d15ce9caa
commit
ecfb6d8a04
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in New Issue