Browse Source

kernel: userspace: Fix memory leak in dynamic_object_create

If memory allocation for a dynamic object fails, an attempt is made to free
a null pointer instead of the allocated element of the dynamic object list.

Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
pull/89100/head
Adrian Warecki 2 months ago committed by Fabio Baltieri
parent
commit
042bf2c3fa
  1. 2
      kernel/userspace.c

2
kernel/userspace.c

@ -364,7 +364,7 @@ static struct k_object *dynamic_object_create(enum k_objects otype, size_t align @@ -364,7 +364,7 @@ static struct k_object *dynamic_object_create(enum k_objects otype, size_t align
} else {
dyn->data = z_thread_aligned_alloc(align, obj_size_get(otype) + size);
if (dyn->data == NULL) {
k_free(dyn->data);
k_free(dyn);
return NULL;
}
dyn->kobj.name = dyn->data;

Loading…
Cancel
Save