summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorToshi Kani <toshi.kani@hpe.com>2016-02-20 14:32:24 -0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2016-03-03 15:07:08 -0800
commitbb7d70e1c3cefe4785a291af49c48ff70cf1525c (patch)
tree0238c3511bf8e68dd700b0b774020a22e896cc13 /kernel
parentaa5f10879d2d745b67a0b21c91d788d8ac6717fe (diff)
devm_memremap: Fix error value when memremap failed
commit 93f834df9c2d4e362dfdc4b05daa0a4e18814836 upstream. devm_memremap() returns an ERR_PTR() value in case of error. However, it returns NULL when memremap() failed. This causes the caller, such as the pmem driver, to proceed and oops later. Change devm_memremap() to return ERR_PTR(-ENXIO) when memremap() failed. Signed-off-by: Toshi Kani <toshi.kani@hpe.com> Cc: Andrew Morton <akpm@linux-foundation.org> Reviewed-by: Ross Zwisler <ross.zwisler@linux.intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/memremap.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/kernel/memremap.c b/kernel/memremap.c
index 7a4e473cea4d..25ced161ebeb 100644
--- a/kernel/memremap.c
+++ b/kernel/memremap.c
@@ -133,8 +133,10 @@ void *devm_memremap(struct device *dev, resource_size_t offset,
if (addr) {
*ptr = addr;
devres_add(dev, ptr);
- } else
+ } else {
devres_free(ptr);
+ return ERR_PTR(-ENXIO);
+ }
return addr;
}