Commit cbd0c0fc authored by Jan H. Schönherr's avatar Jan H. Schönherr Committed by Greg Kroah-Hartman

mm: Fix memory size alignment in devm_memremap_pages_release()

commit 10a0cd6e 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: 5f29a77c ("mm: fix mixed zone detection in devm_memremap_pages")
Signed-off-by: default avatarJan H. Schönherr <jschoenh@amazon.de>
Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 73184545
...@@ -245,7 +245,8 @@ static void devm_memremap_pages_release(struct device *dev, void *data) ...@@ -245,7 +245,8 @@ static void devm_memremap_pages_release(struct device *dev, void *data)
/* pages are dead and unused, undo the arch mapping */ /* pages are dead and unused, undo the arch mapping */
align_start = res->start & ~(SECTION_SIZE - 1); 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(); lock_device_hotplug();
mem_hotplug_begin(); mem_hotplug_begin();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment