Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions zephyr/lib/fast-get.c
Original file line number Diff line number Diff line change
Expand Up @@ -300,10 +300,10 @@ void fast_put(struct k_heap *heap, const void *sram_ptr)
.size = ALIGN_UP(entry->size, CONFIG_MM_DRV_PAGE_SIZE),
.attr = K_MEM_PARTITION_P_RO_U_RO | XTENSA_MMU_CACHED_WB,
};
struct k_mem_domain *domain = k_current_get()->mem_domain_info.mem_domain;
struct k_mem_domain *domain = entry->thread->mem_domain_info.mem_domain;

LOG_DBG("removing partition %p size %#zx from thread %p",
(void *)part.start, part.size, k_current_get());
(void *)part.start, part.size, entry->thread);
int err = k_mem_domain_remove_partition(domain, &part);
Comment on lines +303 to 307
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast_get() can grant additional access by adding the partition to k_current_get() when it differs from entry->thread (see the additional-access path). With this change, fast_put() always removes the partition from entry->thread’s domain, so a thread that received additional access will never remove its own partition (k_mem_domain_remove_partition() will likely fail and the partition will leak). Consider removing from the calling thread’s domain when it contains the partition, and only falling back to entry->thread (or track/remove partitions per granted thread) so both multi-thread use and cross-thread cleanup work.

Copilot uses AI. Check for mistakes.

if (err)
Expand Down
Loading