[PATCH 4.14 069/183] libnvdimm, pfn: Fix over-trim in trim_pfn_device()

From: Greg Kroah-Hartman
Date: Fri Mar 22 2019 - 07:49:36 EST

4.14-stable review patch. If anyone has any objections, please let me know.


From: Wei Yang <richardw.yang@xxxxxxxxxxxxxxx>

commit f101ada7da6551127d192c2f1742c1e9e0f62799 upstream.

When trying to see whether current nd_region intersects with others,
trim_pfn_device() has already calculated the *size* to be expanded to

Do not double append 'adjust' to 'size' when calculating whether the end
of a region collides with the next pmem region.

Fixes: ae86cbfef381 "libnvdimm, pfn: Pad pfn namespaces relative to other regions"
Cc: <stable@xxxxxxxxxxxxxxx>
Signed-off-by: Wei Yang <richardw.yang@xxxxxxxxxxxxxxx>
Signed-off-by: Dan Williams <dan.j.williams@xxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>

drivers/nvdimm/pfn_devs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/nvdimm/pfn_devs.c
+++ b/drivers/nvdimm/pfn_devs.c
@@ -618,7 +618,7 @@ static void trim_pfn_device(struct nd_pf
if (region_intersects(start, size, IORESOURCE_SYSTEM_RAM,
|| !IS_ALIGNED(end, nd_pfn->align)
- || nd_region_conflict(nd_region, start, size + adjust))
+ || nd_region_conflict(nd_region, start, size))
*end_trunc = end - phys_pmem_align_down(nd_pfn, end);