Skip to content

Commit 042bf2c

Browse files
softwareckifabiobaltieri
authored andcommitted
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 <[email protected]>
1 parent b78d1a1 commit 042bf2c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

kernel/userspace.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ static struct k_object *dynamic_object_create(enum k_objects otype, size_t align
364364
} else {
365365
dyn->data = z_thread_aligned_alloc(align, obj_size_get(otype) + size);
366366
if (dyn->data == NULL) {
367-
k_free(dyn->data);
367+
k_free(dyn);
368368
return NULL;
369369
}
370370
dyn->kobj.name = dyn->data;

0 commit comments

Comments
 (0)