From fade4399d2a47a3ff9c5ecd5dd4c3cba7a4eace7 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Wed, 5 Nov 2025 12:01:21 +0100 Subject: [PATCH] lib: utils/irqchip: plic: context_id is signed 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 Reviewed-by: Anup Patel Link: https://lore.kernel.org/r/20251105110121.47130-1-heinrich.schuchardt@canonical.com Signed-off-by: Anup Patel --- 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;