mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2025-08-24 15:31:22 +01:00
lib: prevent coldboot_lottery from overflowing
HSM_STOP will trigger multiple executions of sbi_init, atomic_add_return may trigger coldboot_lottery overflow Signed-off-by: Xiang Wang <merle@hardenedlinux.org> Reviewed-by: Anup Patel <anup.patel@wdc.com>
This commit is contained in:
@@ -285,7 +285,7 @@ void __noreturn sbi_init(struct sbi_scratch *scratch)
|
||||
sbi_platform_hart_invalid(plat, hartid))
|
||||
sbi_hart_hang();
|
||||
|
||||
if (atomic_add_return(&coldboot_lottery, 1) == 1)
|
||||
if (arch_atomic_xchg(&coldboot_lottery, 1) == 0)
|
||||
coldboot = TRUE;
|
||||
|
||||
if (coldboot)
|
||||
|
Reference in New Issue
Block a user