Skip to content

Commit b4734d5

Browse files
Jay Shoenmmahadevan108
authored andcommitted
kernel: kheap: fix k_heap_aligned_alloc handling of K_FOREVER
k_heap_aligned_alloc was not handling K_FOREVER timeout correctly due to unsigned return value. Added explicit K_FOREVER handling of end time. Fixes #50611. Signed-off-by: Jay Shoen <jay.shoen@perceive.io>
1 parent c90b4a4 commit b4734d5

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

kernel/kheap.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ void *k_heap_aligned_alloc(struct k_heap *h, size_t align, size_t bytes,
6666
{
6767
int64_t now, end = sys_clock_timeout_end_calc(timeout);
6868
void *ret = NULL;
69+
70+
end = K_TIMEOUT_EQ(timeout, K_FOREVER) ? INT64_MAX : end;
71+
6972
k_spinlock_key_t key = k_spin_lock(&h->lock);
7073

7174
SYS_PORT_TRACING_OBJ_FUNC_ENTER(k_heap, aligned_alloc, h, timeout);

0 commit comments

Comments
 (0)