Skip to contentSkip to conversation

lib/copperplate: Also deregister main thread from registry sysgroup

PATCH New Jan Kiszka 1 participant 1 message Mar 22, 2023

lore
Share & tools
lore

Jan Kiszka

author
#0 lore raw

PATCH 1/1 lib/copperplate: Also deregister main thread from registry sysgroup

From: Jan Kiszka <[email protected]>

Before 6b4337fed433, we were leaking the object so that the forgotten deregistration caused no major harm. Now that we delete it, it's easy to crash on later accesses to the thread sysgroup.

---
 lib/copperplate/threadobj.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
lib/copperplate/threadobj.c +4 -1
index 6808bcf164..db18f4ffa3 100644
@@ -1773,7 +1773,10 @@ int threadobj_set_schedprio(struct threadobj *thobj, int priority)
 #ifdef CONFIG_XENO_PSHARED
 static void main_exit(void)
 {
-	threadobj_free(threadobj_current());
+	struct threadobj *thobj = threadobj_current();
+
+	sysgroup_remove(thread, &thobj->memspec);
+	threadobj_free(thobj);
 }
 #endif
 
Signature · 1 line
2.35.3