* request for 4.14-stable: 77dd66a3c67c ("mm: Fix devm_memremap_pages() collision handling")
@ 2018-08-27 18:37 Sudip Mukherjee
0 siblings, 0 replies; only message in thread
From: Sudip Mukherjee @ 2018-08-27 18:37 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: stable, Jan H. Schönherr, Dan Williams
[-- Attachment #1: Type: text/plain, Size: 89 bytes --]
Hi Greg,
This was missing in 4.14-stable. Please apply to your queue.
--
Regards
Sudip
[-- Attachment #2: 0001-mm-Fix-devm_memremap_pages-collision-handling.patch --]
[-- Type: text/x-diff, Size: 2536 bytes --]
>From 25c1cf7b4a0e7fa16c9529aca22b951b45d0fd42 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan=20H=2E=20Sch=C3=B6nherr?= <jschoenh@amazon.de>
Date: Fri, 19 Jan 2018 16:26:33 -0800
Subject: [PATCH] mm: Fix devm_memremap_pages() collision handling
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
commit 77dd66a3c67c93ab401ccc15efff25578be281fd upstream
If devm_memremap_pages() detects a collision while adding entries
to the radix-tree, we call pgmap_radix_release(). Unfortunately,
the function removes *all* entries for the range -- including the
entries that caused the collision in the first place.
Modify pgmap_radix_release() to take an additional argument to
indicate where to stop, so that only newly added entries are removed
from the tree.
Cc: <stable@vger.kernel.org>
Fixes: 9476df7d80df ("mm: introduce find_dev_pagemap()")
Signed-off-by: Jan H. Sch�nherr <jschoenh@amazon.de>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
---
kernel/memremap.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/kernel/memremap.c b/kernel/memremap.c
index 4712ce646e04..2b136d4988f7 100644
--- a/kernel/memremap.c
+++ b/kernel/memremap.c
@@ -248,13 +248,16 @@ int device_private_entry_fault(struct vm_area_struct *vma,
EXPORT_SYMBOL(device_private_entry_fault);
#endif /* CONFIG_DEVICE_PRIVATE */
-static void pgmap_radix_release(struct resource *res)
+static void pgmap_radix_release(struct resource *res, unsigned long end_pgoff)
{
unsigned long pgoff, order;
mutex_lock(&pgmap_lock);
- foreach_order_pgoff(res, order, pgoff)
+ foreach_order_pgoff(res, order, pgoff) {
+ if (pgoff >= end_pgoff)
+ break;
radix_tree_delete(&pgmap_radix, PHYS_PFN(res->start) + pgoff);
+ }
mutex_unlock(&pgmap_lock);
synchronize_rcu();
@@ -309,7 +312,7 @@ static void devm_memremap_pages_release(struct device *dev, void *data)
mem_hotplug_done();
untrack_pfn(NULL, PHYS_PFN(align_start), align_size);
- pgmap_radix_release(res);
+ pgmap_radix_release(res, -1);
dev_WARN_ONCE(dev, pgmap->altmap && pgmap->altmap->alloc,
"%s: failed to free all reserved pages\n", __func__);
}
@@ -459,7 +462,7 @@ void *devm_memremap_pages(struct device *dev, struct resource *res,
untrack_pfn(NULL, PHYS_PFN(align_start), align_size);
err_pfn_remap:
err_radix:
- pgmap_radix_release(res);
+ pgmap_radix_release(res, pgoff);
devres_free(page_map);
return ERR_PTR(error);
}
--
2.11.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2018-08-27 22:26 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-08-27 18:37 request for 4.14-stable: 77dd66a3c67c ("mm: Fix devm_memremap_pages() collision handling") Sudip Mukherjee
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox