Skip to content

Commit fdc1c48

Browse files
committed
schedule: zephyr_dp: validate module and task pointers in scheduler_dp_thread_ipc
Move task_dp_pdata assignment after checking pmod and validate pmod->dev, pmod->dev->task, and pmod->dev->task->priv_data pointers before dereferencing to prevent NULL pointer crashes. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
1 parent 70615c4 commit fdc1c48

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/schedule/zephyr_dp_schedule_application.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,14 +154,20 @@ static void ipc_thread_unflatten_run(struct processing_module *pmod, struct ipc4
154154
int scheduler_dp_thread_ipc(struct processing_module *pmod, unsigned int cmd,
155155
const union scheduler_dp_thread_ipc_param *param)
156156
{
157-
struct task_dp_pdata *pdata = pmod->dev->task->priv_data;
158157
int ret;
159158

160159
if (!pmod) {
161160
tr_err(&dp_tr, "no thread module");
162161
return -EINVAL;
163162
}
164163

164+
if (!pmod->dev || !pmod->dev->task || !pmod->dev->task->priv_data) {
165+
tr_err(&dp_tr, "no thread task or pdata");
166+
return -EINVAL;
167+
}
168+
169+
struct task_dp_pdata *pdata = pmod->dev->task->priv_data;
170+
165171
if (cmd == SOF_IPC4_MOD_INIT_INSTANCE) {
166172
/* Wait for the DP thread to start */
167173
ret = k_sem_take(&dp_sync[pmod->dev->task->core], DP_THREAD_IPC_TIMEOUT);

0 commit comments

Comments
 (0)