userspace: plug thread index leak in k_object_alloc()

The thread index should be freed when the object allocation fails.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
This commit is contained in:
Nicolas Pitre 2022-03-13 18:28:59 -04:00 committed by Anas Nashif
commit 962b374129

View file

@ -361,6 +361,9 @@ void *z_impl_k_object_alloc(enum k_objects otype)
zo = z_dynamic_object_aligned_create(obj_align_get(otype),
obj_size_get(otype));
if (zo == NULL) {
if (otype == K_OBJ_THREAD) {
thread_idx_free(tidx);
}
return NULL;
}
zo->type = otype;