All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] memblock: fix memblock_next_valid_pfn()
@ 2017-03-03  2:37 ` AKASHI Takahiro
  0 siblings, 0 replies; 2+ messages in thread
From: AKASHI Takahiro @ 2017-03-03  2:37 UTC (permalink / raw)
  To: akpm; +Cc: paul.burton, linux-kernel, linux-mm, AKASHI Takahiro

Obviously, we should not access memblock.memory.regions[right]
if 'right' is outside of [0..memblock.memory.cnt>.

Fixes: b92df1de5d28 ("mm: page_alloc: skip over regions of invalid pfns where possible")
Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
---
 mm/memblock.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/mm/memblock.c b/mm/memblock.c
index b64b47803e52..696f06d17c4e 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -1118,7 +1118,10 @@ unsigned long __init_memblock memblock_next_valid_pfn(unsigned long pfn,
 		}
 	} while (left < right);
 
-	return min(PHYS_PFN(type->regions[right].base), max_pfn);
+	if (right == type->cnt)
+		return max_pfn;
+	else
+		return min(PHYS_PFN(type->regions[right].base), max_pfn);
 }
 
 /**
-- 
2.11.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH] memblock: fix memblock_next_valid_pfn()
@ 2017-03-03  2:37 ` AKASHI Takahiro
  0 siblings, 0 replies; 2+ messages in thread
From: AKASHI Takahiro @ 2017-03-03  2:37 UTC (permalink / raw)
  To: akpm; +Cc: paul.burton, linux-kernel, linux-mm, AKASHI Takahiro

Obviously, we should not access memblock.memory.regions[right]
if 'right' is outside of [0..memblock.memory.cnt>.

Fixes: b92df1de5d28 ("mm: page_alloc: skip over regions of invalid pfns where possible")
Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
---
 mm/memblock.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/mm/memblock.c b/mm/memblock.c
index b64b47803e52..696f06d17c4e 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -1118,7 +1118,10 @@ unsigned long __init_memblock memblock_next_valid_pfn(unsigned long pfn,
 		}
 	} while (left < right);
 
-	return min(PHYS_PFN(type->regions[right].base), max_pfn);
+	if (right == type->cnt)
+		return max_pfn;
+	else
+		return min(PHYS_PFN(type->regions[right].base), max_pfn);
 }
 
 /**
-- 
2.11.1

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-03-03  3:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-03  2:37 [PATCH] memblock: fix memblock_next_valid_pfn() AKASHI Takahiro
2017-03-03  2:37 ` AKASHI Takahiro

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.