[lib][trusty] Fix crash in current_trusty_app
If the current thread is not a trusty thread, return NULL instead of
crashing.
Fixes infinite crash loop on 32 bit arm kernel if a kernel thread
crashes.
Bug: 80146040
Change-Id: I3d3246a08de4e0a3c2acf085b9de56b3e2df8d3c
diff --git a/lib/trusty/include/lib/trusty/trusty_app.h b/lib/trusty/include/lib/trusty/trusty_app.h
index e2060b0..a72cc5f 100644
--- a/lib/trusty/include/lib/trusty/trusty_app.h
+++ b/lib/trusty/include/lib/trusty/trusty_app.h
@@ -173,7 +173,11 @@
}
static inline struct trusty_app* current_trusty_app(void) {
- return current_trusty_thread()->app;
+ struct trusty_thread* trusty_thread = current_trusty_thread();
+ if (!trusty_thread) {
+ return NULL;
+ }
+ return trusty_thread->app;
}
#endif