diff --git a/include/evl/factory.h b/include/evl/factory.h index 2698d378b82789..c5bb1a58aa5b19 100644 --- a/include/evl/factory.h +++ b/include/evl/factory.h @@ -143,6 +143,14 @@ __evl_get_element_by_fundle(struct evl_index *map, container_of(__e, __type, element); }) : NULL; \ }) +/* Hide the element from sysfs operations. */ +static inline void evl_hide_element(struct evl_element *e) +{ + struct device *dev = e->dev; + if (dev) + dev_set_drvdata(dev, NULL); +} + static inline bool evl_element_is_public(struct evl_element *e) { return !!(e->clone_flags & EVL_CLONE_PUBLIC); diff --git a/kernel/evl/thread.c b/kernel/evl/thread.c index 799195242dd69a..4647a58b93daf7 100644 --- a/kernel/evl/thread.c +++ b/kernel/evl/thread.c @@ -277,6 +277,14 @@ static void uninit_thread(struct evl_thread *thread) unsigned long flags; struct evl_rq *rq; + /* + * Threads are special elements in that they may exit + * independently from the existence of their respective + * backing cdev. Make sure to hide exiting threads from sysfs + * handlers before we dismantle things. + */ + evl_hide_element(&thread->element); + evl_destroy_timer(&thread->rtimer); evl_destroy_timer(&thread->ptimer);