mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2025-08-24 15:31:22 +01:00
lib: utils/irqchip: Add sanity checks in imsic_get_data() and imsic_get_target_file()
Add extra sanity checks to prevent the caller getting the invalid result from imsic_get_data() or imsic_get_target_file() when imsic is not initialized correctly. Signed-off-by: Cyan Yang <cyan.yang@sifive.com> Reviewed-by: Anup Patel <anup@brainfault.org>
This commit is contained in:
@@ -123,6 +123,9 @@ struct imsic_data *imsic_get_data(u32 hartid)
|
||||
{
|
||||
struct sbi_scratch *scratch;
|
||||
|
||||
if (!imsic_ptr_offset)
|
||||
return NULL;
|
||||
|
||||
scratch = sbi_hartid_to_scratch(hartid);
|
||||
if (!scratch)
|
||||
return NULL;
|
||||
@@ -134,6 +137,9 @@ int imsic_get_target_file(u32 hartid)
|
||||
{
|
||||
struct sbi_scratch *scratch;
|
||||
|
||||
if (!imsic_file_offset)
|
||||
return SBI_ENOENT;
|
||||
|
||||
scratch = sbi_hartid_to_scratch(hartid);
|
||||
if (!scratch)
|
||||
return SBI_ENOENT;
|
||||
|
Reference in New Issue
Block a user