diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2022-02-26 12:00:44 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2022-02-26 12:00:44 -0800 |
commit | e41898d2ba51ef2e8e81fb905c1eaa958aec830a (patch) | |
tree | c1693e1669bd4c9af3694b927e8b6817aa5e0b36 | |
parent | 086ee11b0384c5ee837a46fac36e38189717960b (diff) | |
parent | c94afc46cae7ad41b2ad6a99368147879f4b0e56 (diff) | |
download | linux-e41898d2ba51ef2e8e81fb905c1eaa958aec830a.tar.gz linux-e41898d2ba51ef2e8e81fb905c1eaa958aec830a.tar.bz2 linux-e41898d2ba51ef2e8e81fb905c1eaa958aec830a.zip |
Merge tag 'fixes-2022-02-26' of git://git.kernel.org/pub/scm/linux/kernel/git/rppt/memblock
Pull memblock fix from Mike Rapoport:
"Use kfree() to release kmalloced memblock regions
memblock.{reserved,memory}.regions may be allocated using kmalloc()
in memblock_double_array(). Use kfree() to release these kmalloced
regions"
* tag 'fixes-2022-02-26' of git://git.kernel.org/pub/scm/linux/kernel/git/rppt/memblock:
memblock: use kfree() to release kmalloced memblock regions
-rw-r--r-- | mm/memblock.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/mm/memblock.c b/mm/memblock.c index 1018e50566f3..b12a364f2766 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -366,14 +366,20 @@ void __init memblock_discard(void) addr = __pa(memblock.reserved.regions); size = PAGE_ALIGN(sizeof(struct memblock_region) * memblock.reserved.max); - memblock_free_late(addr, size); + if (memblock_reserved_in_slab) + kfree(memblock.reserved.regions); + else + memblock_free_late(addr, size); } if (memblock.memory.regions != memblock_memory_init_regions) { addr = __pa(memblock.memory.regions); size = PAGE_ALIGN(sizeof(struct memblock_region) * memblock.memory.max); - memblock_free_late(addr, size); + if (memblock_memory_in_slab) + kfree(memblock.memory.regions); + else + memblock_free_late(addr, size); } memblock_memory = NULL; |