diff options
author | Xiang Wang <merle@hardenedlinux.org> | 2020-03-24 13:11:48 +0300 |
---|---|---|
committer | Anup Patel <anup@brainfault.org> | 2020-03-26 15:02:34 +0300 |
commit | 4d93586bfa9a6875f1f28c5f430b17b650a19207 (patch) | |
tree | 70752f3b56b16fc44626c8ac3d75f5bad56f165b /lib | |
parent | 4c374511fd893ee4a7c7f1b225307f7d257e6bf1 (diff) | |
download | opensbi-4d93586bfa9a6875f1f28c5f430b17b650a19207.tar.xz |
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>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/sbi/sbi_init.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/sbi/sbi_init.c b/lib/sbi/sbi_init.c index 90ec64c..4e1699d 100644 --- a/lib/sbi/sbi_init.c +++ b/lib/sbi/sbi_init.c @@ -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) |