diff --git a/src/audio/multiband_drc/multiband_drc.c b/src/audio/multiband_drc/multiband_drc.c index e10b63d28d9a..8356111451ad 100644 --- a/src/audio/multiband_drc/multiband_drc.c +++ b/src/audio/multiband_drc/multiband_drc.c @@ -64,20 +64,25 @@ static void multiband_drc_reset_state(struct multiband_drc_state *state) multiband_drc_iir_reset_state_ch(&state->deemphasis[i]); } -static int multiband_drc_eq_init_coef_ch(struct sof_eq_iir_biquad *coef, +static int multiband_drc_eq_init_coef_ch(struct comp_dev *dev, struct sof_eq_iir_biquad *coef, struct iir_state_df2t *eq) { int ret; eq->coef = rzalloc(SOF_MEM_ZONE_RUNTIME, 0, SOF_MEM_CAPS_RAM, sizeof(struct sof_eq_iir_biquad) * SOF_EMP_DEEMP_BIQUADS); - if (!eq->coef) + if (!eq->coef) { + comp_err(dev, "Failed to allocate EQ coefficients"); return -ENOMEM; + } /* Coefficients of the first biquad and second biquad */ ret = memcpy_s(eq->coef, sizeof(struct sof_eq_iir_biquad) * SOF_EMP_DEEMP_BIQUADS, coef, sizeof(struct sof_eq_iir_biquad) * SOF_EMP_DEEMP_BIQUADS); - assert(!ret); + if (ret) { + comp_err(dev, "Memory copy failed"); + return ret; + } /* EQ filters are two 2nd order filters, so only need 4 delay slots * delay[0..1] -> state for first biquad @@ -146,7 +151,7 @@ static int multiband_drc_init_coef(struct processing_module *mod, int16_t nch, u /* Emphasis: collect the coef array and assign it to every channel */ emphasis = config->emp_coef; for (ch = 0; ch < nch; ch++) { - ret = multiband_drc_eq_init_coef_ch(emphasis, &state->emphasis[ch]); + ret = multiband_drc_eq_init_coef_ch(dev, emphasis, &state->emphasis[ch]); /* Free all previously allocated blocks in case of an error */ if (ret < 0) { comp_err(dev, "multiband_drc_init_coef(), could not assign coeffs to ch %d", @@ -160,7 +165,7 @@ static int multiband_drc_init_coef(struct processing_module *mod, int16_t nch, u /* Deemphasis: collect the coef array and assign it to every channel */ deemphasis = config->deemp_coef; for (ch = 0; ch < nch; ch++) { - ret = multiband_drc_eq_init_coef_ch(deemphasis, &state->deemphasis[ch]); + ret = multiband_drc_eq_init_coef_ch(dev, deemphasis, &state->deemphasis[ch]); /* Free all previously allocated blocks in case of an error */ if (ret < 0) { comp_err(dev, "multiband_drc_init_coef(), could not assign coeffs to ch %d", @@ -205,10 +210,8 @@ static int multiband_drc_setup(struct processing_module *mod, int16_t channels, /* Setup Crossover, Emphasis EQ, Deemphasis EQ, and DRC */ ret = multiband_drc_init_coef(mod, channels, rate); - if (ret < 0) - return ret; - - return 0; + /* This will return 0 if no error occurred, or the negative error code. */ + return ret; } /*