]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
mm: Fix memory size alignment in devm_memremap_pages_release()
authorJan H. Schönherr <jschoenh@amazon.de>
Sat, 20 Jan 2018 00:27:54 +0000 (16:27 -0800)
committerSeth Forshee <seth.forshee@canonical.com>
Fri, 23 Feb 2018 14:27:21 +0000 (08:27 -0600)
BugLink: http://bugs.launchpad.net/bugs/1751131
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>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
kernel/memremap.c

index 403ab9cdb949a0483bd82c811a3383eed77e5246..4712ce646e04b5690c59232a947a733143980e32 100644 (file)
@@ -301,7 +301,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;
 
        mem_hotplug_begin();
        arch_remove_memory(align_start, align_size);