Skip to content

Commit

Permalink
devm_memremap: Fix error value when memremap failed
Browse files Browse the repository at this point in the history
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 <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: <[email protected]>
Reviewed-by: Ross Zwisler <[email protected]>
Signed-off-by: Dan Williams <[email protected]>
  • Loading branch information
toshikani authored and djbw committed Feb 24, 2016
1 parent 4577b06 commit 93f834d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion kernel/memremap.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,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;
}
Expand Down

0 comments on commit 93f834d

Please sign in to comment.