Skip to content
Commit 2d1704c3 authored by Petr Pavlu's avatar Petr Pavlu Committed by Sasha Levin
Browse files

riscv: Fix a number of free'd resources in init_resources()

[ Upstream commit aa3e1ba3 ]

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: ffe0e526

 ("RISC-V: Improve init_resources()")
Signed-off-by: default avatarPetr Pavlu <petr.pavlu@suse.com>
Reviewed-by: default avatarSunil V L <sunilvl@ventanamicro.com>
Acked-by: default avatarNick Kossifidis <mick@ics.forth.gr>
Tested-by: default avatarSunil V L <sunilvl@ventanamicro.com>
Cc: stable@vger.kernel.org
Signed-off-by: default avatarPalmer Dabbelt <palmerdabbelt@google.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 8c5beac9
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment