From: Toshi Kani Date: Sat, 20 Feb 2016 22:32:24 +0000 (-0800) Subject: devm_memremap: Fix error value when memremap failed X-Git-Tag: firefly_0821_release~176^2~475^2~366 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=bb7d70e1c3cefe4785a291af49c48ff70cf1525c;p=firefly-linux-kernel-4.4.55.git 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 Cc: Andrew Morton Reviewed-by: Ross Zwisler Signed-off-by: Dan Williams Signed-off-by: Greg Kroah-Hartman --- 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; }