diff --git a/src/arch/xtensa/include/arch/task.h b/src/arch/xtensa/include/arch/task.h index cae0e71ed4cc..fa5a372b345a 100644 --- a/src/arch/xtensa/include/arch/task.h +++ b/src/arch/xtensa/include/arch/task.h @@ -167,11 +167,15 @@ static inline void arch_run_task(struct task *task) /** * \brief Allocates IRQ tasks. */ -static inline void arch_allocate_tasks(void) +static inline int arch_allocate_tasks(void) { /* irq low */ struct irq_task **low = task_irq_low_get(); *low = rzalloc(RZONE_RUNTIME, SOF_MEM_CAPS_RAM, sizeof(**low)); + + if (!*low) + return -ENOMEM; + list_init(&((*low)->list)); spinlock_init(&((*low)->lock)); (*low)->irq = PLATFORM_IRQ_TASK_LOW; @@ -179,6 +183,10 @@ static inline void arch_allocate_tasks(void) /* irq medium */ struct irq_task **med = task_irq_med_get(); *med = rzalloc(RZONE_RUNTIME, SOF_MEM_CAPS_RAM, sizeof(**med)); + + if (!*med) + return -ENOMEM; + list_init(&((*med)->list)); spinlock_init(&((*med)->lock)); (*med)->irq = PLATFORM_IRQ_TASK_MED; @@ -186,9 +194,15 @@ static inline void arch_allocate_tasks(void) /* irq high */ struct irq_task **high = task_irq_high_get(); *high = rzalloc(RZONE_RUNTIME, SOF_MEM_CAPS_RAM, sizeof(**high)); + + if (!*high) + return -ENOMEM; + list_init(&((*high)->list)); spinlock_init(&((*high)->lock)); (*high)->irq = PLATFORM_IRQ_TASK_HIGH; + + return 0; } /** diff --git a/src/audio/eq_fir.c b/src/audio/eq_fir.c index 5dbd17339492..b31b5619e3b7 100644 --- a/src/audio/eq_fir.c +++ b/src/audio/eq_fir.c @@ -345,12 +345,23 @@ static int fir_cmd_get_data(struct comp_dev *dev, case SOF_CTRL_CMD_BINARY: trace_eq("gbi"); + struct sof_eq_fir_config *cfg = + (struct sof_eq_fir_config *)cdata->data->data; + /* Copy back to user space */ - bs = cd->config->size; + bs = cfg->size; if (bs > SOF_EQ_FIR_MAX_SIZE || bs < 1) return -EINVAL; - if (!cd->config) + if (!cd->config) { + cd->config = rzalloc(RZONE_RUNTIME, + SOF_MEM_CAPS_RAM, + bs); + + if (!cd->config) + return -ENOMEM; + memcpy(cdata->data->data, cd->config, bs); + } break; default: trace_eq_error("egt"); diff --git a/src/include/sof/task.h b/src/include/sof/task.h index 747d95843975..15fe0d04f1ac 100644 --- a/src/include/sof/task.h +++ b/src/include/sof/task.h @@ -40,9 +40,9 @@ int do_task_master_core(struct sof *sof); int do_task_slave_core(struct sof *sof); -static inline void allocate_tasks(void) +static inline int allocate_tasks(void) { - arch_allocate_tasks(); + return arch_allocate_tasks(); } static inline void run_task(struct task *task) diff --git a/src/lib/schedule.c b/src/lib/schedule.c index 22296854e00f..e5a220c0bd5c 100644 --- a/src/lib/schedule.c +++ b/src/lib/schedule.c @@ -375,6 +375,10 @@ int scheduler_init(struct sof *sof) struct schedule_data **sch = arch_schedule_get(); *sch = rzalloc(RZONE_RUNTIME, SOF_MEM_CAPS_RAM, sizeof(**sch)); + + if (!*sch) + return -ENOMEM; + list_init(&((*sch)->list)); spinlock_init(&((*sch)->lock)); (*sch)->clock = PLATFORM_SCHED_CLOCK; @@ -385,9 +389,9 @@ int scheduler_init(struct sof *sof) interrupt_enable(PLATFORM_SCHEDULE_IRQ); /* allocate arch tasks */ - allocate_tasks(); + int tasks_result = allocate_tasks(); - return 0; + return tasks_result; } /* Frees scheduler */