userspace: do nothing if added to same domain

If we call k_mem_domain_add_thread() to a memory domain
the thread already belongs to, do nothing.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
Andrew Boie 2020-10-20 13:26:19 -07:00 committed by Andrew Boie
commit fa6db61eb2

View file

@ -262,8 +262,10 @@ void k_mem_domain_add_thread(struct k_mem_domain *domain, k_tid_t thread)
k_spinlock_key_t key;
key = k_spin_lock(&z_mem_domain_lock);
remove_thread_locked(thread);
add_thread_locked(domain, thread);
if (thread->mem_domain_info.mem_domain != domain) {
remove_thread_locked(thread);
add_thread_locked(domain, thread);
}
k_spin_unlock(&z_mem_domain_lock, key);
}