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_ipi.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_ipi.c')
-rw-r--r-- | lib/sbi/sbi_ipi.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/sbi/sbi_ipi.c b/lib/sbi/sbi_ipi.c index fdd6e8a..78db752 100644 --- a/lib/sbi/sbi_ipi.c +++ b/lib/sbi/sbi_ipi.c @@ -41,11 +41,10 @@ static int sbi_ipi_send(struct sbi_scratch *scratch, u32 remote_hartid, return SBI_EINVAL; ipi_ops = ipi_ops_array[event]; - /* - * Set IPI type on remote hart's scratch area and - * trigger the interrupt - */ remote_scratch = sbi_hartid_to_scratch(remote_hartid); + if (!remote_scratch) + return SBI_EINVAL; + ipi_data = sbi_scratch_offset_ptr(remote_scratch, ipi_data_off); if (ipi_ops->update) { @@ -55,6 +54,10 @@ static int sbi_ipi_send(struct sbi_scratch *scratch, u32 remote_hartid, return ret; } + /* + * Set IPI type on remote hart's scratch area and + * trigger the interrupt + */ atomic_raw_set_bit(event, &ipi_data->ipi_type); smp_wmb(); sbi_platform_ipi_send(plat, remote_hartid); |