summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorJan H. Schönherr <jschoenh@amazon.de>2018-01-19 16:27:54 -0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-02-22 15:43:48 +0100
commitcbd0c0fc54e2fa27d05779cb984fe9c989652be8 (patch)
tree9bb2b1498ab5c4e7b3d0365485b30364c57c43a4 /kernel
parent7318454518ad56ad38b60dbb3d185fd14d0d0b93 (diff)
mm: Fix memory size alignment in devm_memremap_pages_release()
commit 10a0cd6e4932b5078215b1ec2c896597eec0eff9 upstream. The functions devm_memremap_pages() and devm_memremap_pages_release() use different ways to calculate the section-aligned amount of memory. The latter function may use an incorrect size if the memory region is small but straddles a section border. Use the same code for both. Cc: <stable@vger.kernel.org> Fixes: 5f29a77cd957 ("mm: fix mixed zone detection in devm_memremap_pages") Signed-off-by: Jan H. Schönherr <jschoenh@amazon.de> 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.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/kernel/memremap.c b/kernel/memremap.c
index 06123234f118..426547a21a0c 100644
--- a/kernel/memremap.c
+++ b/kernel/memremap.c
@@ -245,7 +245,8 @@ static void devm_memremap_pages_release(struct device *dev, void *data)
/* pages are dead and unused, undo the arch mapping */
align_start = res->start & ~(SECTION_SIZE - 1);
- align_size = ALIGN(resource_size(res), SECTION_SIZE);
+ align_size = ALIGN(res->start + resource_size(res), SECTION_SIZE)
+ - align_start;
lock_device_hotplug();
mem_hotplug_begin();