lib: sbi: sse_event_get() may return NULL
authorHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Mon, 8 Apr 2024 07:29:04 +0000 (09:29 +0200)
committerAnup Patel <anup@brainfault.org>
Wed, 10 Apr 2024 04:08:24 +0000 (09:38 +0530)
sse_event_get() may return NULL. We should not dereference the return value
in sbi_sse_exit() without checking.

Fixes: c8cdf01d8f3a ("lib: sbi: Add support for Supervisor Software Events extension")
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
lib/sbi/sbi_sse.c

index a6866922da6e47d4ef92515126cddbb86f8edf2c..f0729f944d1b9eef10d1efb6b6e4b69a7e8f6262 100644 (file)
@@ -1119,7 +1119,7 @@ void sbi_sse_exit(struct sbi_scratch *scratch)
        for (i = 0; i < EVENT_COUNT; i++) {
                e = sse_event_get(supported_events[i]);
 
-               if (e->attrs.hartid != current_hartid())
+               if (!e || e->attrs.hartid != current_hartid())
                        continue;
 
                if (sse_event_state(e) > SBI_SSE_STATE_REGISTERED) {