diff options
author | Anup Patel <anup.patel@wdc.com> | 2020-03-14 18:55:53 +0530 |
---|---|---|
committer | Anup Patel <anup@brainfault.org> | 2020-03-19 09:11:12 +0530 |
commit | 209134d8f9c6e4ec9a555a7813f7e2c004b5b2d7 (patch) | |
tree | 8c9cda3f1891a2bc9f0e1b33c696f58806799335 /lib/sbi/sbi_init.c | |
parent | 3ebfe0ec5d280b0c5ca61b8c5cfe4bc807907630 (diff) |
lib: Handle failure of sbi_hartid_to_scratch() API
The sbi_hartid_to_scratch() API can fail for non-existent HARTs so
all uses of sbi_hartid_to_scratch() API should check return value.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Diffstat (limited to 'lib/sbi/sbi_init.c')
-rw-r--r-- | lib/sbi/sbi_init.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/sbi/sbi_init.c b/lib/sbi/sbi_init.c index 6901528..f75b904 100644 --- a/lib/sbi/sbi_init.c +++ b/lib/sbi/sbi_init.c @@ -305,6 +305,9 @@ unsigned long sbi_init_count(u32 hartid) return 0; scratch = sbi_hartid_to_scratch(hartid); + if (!scratch) + return 0; + init_count = sbi_scratch_offset_ptr(scratch, init_count_offset); return *init_count; |