Skip to content

Commit 45e1158

Browse files
committed
idc: zephyr_idc: check target core before taking idc_mutex
idc_send_msg() acquired idc_mutex and then returned -EACCES on the disabled-core path without unlocking, leaking the mutex and blocking all later cross-core IDC sends. Move the cpu_is_core_enabled() check ahead of the lock so the early return no longer holds the mutex and the per-core work slot is not touched for a disabled core. Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>
1 parent 9cd055b commit 45e1158

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

src/idc/zephyr_idc.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,11 @@ int idc_send_msg(struct idc_msg *msg, uint32_t mode)
135135
int ret;
136136
int idc_send_memcpy_err __unused;
137137

138+
if (!cpu_is_core_enabled(target_cpu)) {
139+
tr_err(&zephyr_idc_tr, "Core %u is down, cannot send IDC message", target_cpu);
140+
return -EACCES;
141+
}
142+
138143
k_mutex_lock(&idc_mutex, K_FOREVER);
139144

140145
if (unlikely(work->thread)) {
@@ -153,10 +158,6 @@ int idc_send_msg(struct idc_msg *msg, uint32_t mode)
153158
work->handler = idc_handler;
154159
work->sync = mode == IDC_BLOCKING;
155160

156-
if (!cpu_is_core_enabled(target_cpu)) {
157-
tr_err(&zephyr_idc_tr, "Core %u is down, cannot sent IDC message", target_cpu);
158-
return -EACCES;
159-
}
160161
if (msg->payload) {
161162
idc_send_memcpy_err = memcpy_s(payload->data, sizeof(payload->data),
162163
msg->payload, msg->size);

0 commit comments

Comments
 (0)