mirror of
https://gitlab.com/qemu-project/opensbi.git
synced 2025-11-10 05:37:55 +08: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