mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2025-08-24 15:31:22 +01:00
lib: sbi: check result of pmp_get() in is_pmp_entry_mapped()
pmp_get() may return an error if the given entry, given by the caller of is_pmp_entry_mapped(), is invalid. This results in the output parameters for pmp_get() being uninitialized. To avoid using garbage values, check the result and return early if necessary. This issue is not being hit because at the moment is_pmp_entry_mapped() is only being called from a single site with a valid hardcoded value. Signed-off-by: Carlos López <carlos.lopezr4096@gmail.com> Reviewed-by: Anup Patel <anup@brainfault.org>
This commit is contained in:
@@ -291,7 +291,8 @@ int is_pmp_entry_mapped(unsigned long entry)
|
||||
unsigned long addr;
|
||||
unsigned long log2len;
|
||||
|
||||
pmp_get(entry, &prot, &addr, &log2len);
|
||||
if (pmp_get(entry, &prot, &addr, &log2len) != 0)
|
||||
return false;
|
||||
|
||||
/* If address matching bits are non-zero, the entry is enable */
|
||||
if (prot & PMP_A)
|
||||
|
Reference in New Issue
Block a user