/* Note, that while we protect the global llext list while searching, we release the lock before returning the found extension to the caller. Therefore it's a responsibility of the caller to protect against races with a freeing context when calling this function.  */
struct llext* llext_by_name(const char *name)
/* Note, that while we protect the global llext list while searching, we release the lock before returning the found extension to the caller. Therefore it's a responsibility of the caller to protect against races with a freeing context when calling this function.  */
struct llext* llext_by_name(const char *name)
{
	k_mutex_lock(&llext_lock, K_FOREVER);
	for (sys_snode_t *node = sys_slist_peek_head(&_llext_list);
	     node != NULL;
	     node = sys_slist_peek_next(node)) {
		struct llext *ext = CONTAINER_OF(node, struct llext, _llext_list);
		if (strncmp(ext->name, name, sizeof(ext->name)) == 0) {
			k_mutex_unlock(&llext_lock);
			return ext;
		}
	}
	k_mutex_unlock(&llext_lock);
	return NULL;
}