]> git.baikalelectronics.ru Git - kernel.git/commit
riscv: Fix a number of free'd resources in init_resources()
authorPetr Pavlu <petr.pavlu@suse.com>
Sat, 7 Aug 2021 17:54:50 +0000 (19:54 +0200)
committerPalmer Dabbelt <palmerdabbelt@google.com>
Fri, 20 Aug 2021 17:15:51 +0000 (10:15 -0700)
commitc696b4662da8dea98f1ddc3db38f8e84985283b5
tree38319ee9fca26c731a07ccbdc67ab2f527a0cd46
parentcf03f63190c65aa7a266daa94fe5d73b93ccf0f6
riscv: Fix a number of free'd resources in init_resources()

Function init_resources() allocates a boot memory block to hold an array of
resources which it adds to iomem_resource. The array is filled in from its
end and the function then attempts to free any unused memory at the
beginning. The problem is that size of the unused memory is incorrectly
calculated and this can result in releasing memory which is in use by
active resources. Their data then gets corrupted later when the memory is
reused by a different part of the system.

Fix the size of the released memory to correctly match the number of unused
resource entries.

Fixes: ec959da4fa47 ("RISC-V: Improve init_resources()")
Signed-off-by: Petr Pavlu <petr.pavlu@suse.com>
Reviewed-by: Sunil V L <sunilvl@ventanamicro.com>
Acked-by: Nick Kossifidis <mick@ics.forth.gr>
Tested-by: Sunil V L <sunilvl@ventanamicro.com>
Cc: stable@vger.kernel.org
Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>
arch/riscv/kernel/setup.c