summaryrefslogtreecommitdiffstats
path: root/mm/memblock.c
diff options
context:
space:
mode:
authorMike Rapoport <rppt@linux.ibm.com>2021-06-30 08:12:13 +0200
committerMike Rapoport <rppt@linux.ibm.com>2021-06-30 10:38:56 +0200
commit023accf5cdc1e504a9b04187ec23ff156fe53d90 (patch)
tree4bd82ea2aa7444345e9d13a3eec68267cc9da07f /mm/memblock.c
parentmemblock: align freed memory map on pageblock boundaries with SPARSEMEM (diff)
downloadlinux-023accf5cdc1e504a9b04187ec23ff156fe53d90.tar.xz
linux-023accf5cdc1e504a9b04187ec23ff156fe53d90.zip
memblock: ensure there is no overflow in memblock_overlaps_region()
There maybe an overflow in memblock_overlaps_region() if it is called with base and size such that base + size > PHYS_ADDR_MAX Make sure that memblock_overlaps_region() caps the size to prevent such overflow and remove now duplicated call to memblock_cap_size() from memblock_is_region_reserved(). Signed-off-by: Mike Rapoport <rppt@linux.ibm.com> Tested-by: Tony Lindgren <tony@atomide.com>
Diffstat (limited to 'mm/memblock.c')
-rw-r--r--mm/memblock.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/mm/memblock.c b/mm/memblock.c
index 2e25d69739e0..67e0e24f8cc9 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -182,6 +182,8 @@ bool __init_memblock memblock_overlaps_region(struct memblock_type *type,
{
unsigned long i;
+ memblock_cap_size(base, &size);
+
for (i = 0; i < type->cnt; i++)
if (memblock_addrs_overlap(base, size, type->regions[i].base,
type->regions[i].size))
@@ -1794,7 +1796,6 @@ bool __init_memblock memblock_is_region_memory(phys_addr_t base, phys_addr_t siz
*/
bool __init_memblock memblock_is_region_reserved(phys_addr_t base, phys_addr_t size)
{
- memblock_cap_size(base, &size);
return memblock_overlaps_region(&memblock.reserved, base, size);
}