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>
This commit is contained in:
parent
b78d1a1c96
commit
042bf2c3fa
1 changed files with 1 additions and 1 deletions
|
@ -364,7 +364,7 @@ static struct k_object *dynamic_object_create(enum k_objects otype, size_t align
|
||||||
} else {
|
} else {
|
||||||
dyn->data = z_thread_aligned_alloc(align, obj_size_get(otype) + size);
|
dyn->data = z_thread_aligned_alloc(align, obj_size_get(otype) + size);
|
||||||
if (dyn->data == NULL) {
|
if (dyn->data == NULL) {
|
||||||
k_free(dyn->data);
|
k_free(dyn);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
dyn->kobj.name = dyn->data;
|
dyn->kobj.name = dyn->data;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue