[PATCH 1/1] lib: sbi_domain: logical constraints in sbi_domain_context_exit()

Heinrich Schuchardt heinrich.schuchardt at canonical.com
Tue Oct 27 17:03:29 PDT 2026


We check that tmp is non-NULL in one statement and in a later statement
we happily dereference it.

If hart_context_get() returns NULL, the hart-domain combination is
obviously invalid and we should simply continue in the loop.

Addresses-Coverity-ID: 1680795 ("Dereference after null check")
Fixes: 55b6b73435ec ("lib: sbi_domain: Introduce domain intialization order")
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt at canonical.com>
---
 lib/sbi/sbi_domain_context.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/sbi/sbi_domain_context.c b/lib/sbi/sbi_domain_context.c
index 987ac7fa..88afbb63 100644
--- a/lib/sbi/sbi_domain_context.c
+++ b/lib/sbi/sbi_domain_context.c
@@ -307,7 +307,7 @@ int sbi_domain_context_exit(void)
 				continue;
 
 			tmp = hart_context_get(dom, hartindex);
-			if (tmp && tmp->initialized)
+			if (!tmp || tmp->initialized)
 				continue;
 
 			if (!dom_ctx || tmp->dom->init_order < dom_ctx->dom->init_order)
-- 
2.53.0




More information about the opensbi mailing list