[PATCH 1/1] lib: utils/irqchip: plic: context_id is signed
Heinrich Schuchardt
heinrich.schuchardt at canonical.com
Wed Nov 5 03:01:21 PST 2025
Array context_id in struct plic_data has elements of type s16.
A negative valid indicates an invalid entry.
Copying the array element to a u32 scalar hides the sign.
Use s16 as target type when copying an array element to a scalar.
Addresses-Coverity-ID: 1667176 Unsigned compared against 0
Addresses-Coverity-ID: 1667178 Logically dead code
Addresses-Coverity-ID: 1667179 Unsigned compared against 0
Addresses-Coverity-ID: 1667182 Logically dead code
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt at canonical.com>
---
lib/utils/irqchip/plic.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/utils/irqchip/plic.c b/lib/utils/irqchip/plic.c
index 581a41bb..7989a962 100644
--- a/lib/utils/irqchip/plic.c
+++ b/lib/utils/irqchip/plic.c
@@ -136,7 +136,7 @@ void plic_suspend(void)
return;
sbi_for_each_hartindex(h) {
- u32 context_id = plic->context_map[h][PLIC_S_CONTEXT];
+ s16 context_id = plic->context_map[h][PLIC_S_CONTEXT];
if (context_id < 0)
continue;
@@ -167,7 +167,7 @@ void plic_resume(void)
return;
sbi_for_each_hartindex(h) {
- u32 context_id = plic->context_map[h][PLIC_S_CONTEXT];
+ s16 context_id = plic->context_map[h][PLIC_S_CONTEXT];
if (context_id < 0)
continue;
--
2.51.0
More information about the opensbi
mailing list