File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -247,11 +247,20 @@ static struct comp_dev *eq_fir_new(struct sof_ipc_comp *comp)
247247 struct comp_data * cd ;
248248 struct sof_ipc_comp_eq_fir * ipc_fir
249249 = (struct sof_ipc_comp_eq_fir * )comp ;
250- size_t bs ;
250+ size_t bs = ipc_fir -> size ;
251251 int i ;
252252
253253 trace_eq ("new" );
254254
255+ /* Check first before proceeding with dev and cd that coefficients
256+ * blob size is sane.
257+ */
258+ if (bs > SOF_EQ_FIR_MAX_SIZE ) {
259+ trace_eq_error ("ens" );
260+ trace_error_value (bs );
261+ return NULL ;
262+ }
263+
255264 dev = rzalloc (RZONE_RUNTIME , SOF_MEM_CAPS_RAM ,
256265 COMP_SIZE (struct sof_ipc_comp_eq_fir ));
257266 if (!dev )
@@ -267,19 +276,14 @@ static struct comp_dev *eq_fir_new(struct sof_ipc_comp *comp)
267276
268277 comp_set_drvdata (dev , cd );
269278
270- bs = ipc_fir -> size ;
271- if (bs > SOF_EQ_FIR_MAX_SIZE ) {
272- rfree (dev );
273- rfree (cd );
274- return NULL ;
275- }
276-
277279 cd -> eq_fir_func = eq_fir_passthrough ;
278280 cd -> eq_fir_func_odd = eq_fir_passthrough ;
279281 cd -> config = NULL ;
280282
281- /* Allocate and make a copy of the blob and setup FIR */
282- if (bs > 0 ) {
283+ /* Allocate and make a copy of the coefficients blob and reset FIR. If
284+ * the EQ is configured later in run-time the size is zero.
285+ */
286+ if (bs ) {
283287 cd -> config = rzalloc (RZONE_RUNTIME , SOF_MEM_CAPS_RAM , bs );
284288 if (!cd -> config ) {
285289 rfree (dev );
Original file line number Diff line number Diff line change @@ -340,11 +340,20 @@ static struct comp_dev *eq_iir_new(struct sof_ipc_comp *comp)
340340 struct comp_data * cd ;
341341 struct sof_ipc_comp_eq_iir * ipc_iir =
342342 (struct sof_ipc_comp_eq_iir * )comp ;
343- size_t bs ;
343+ size_t bs = ipc_iir -> size ;
344344 int i ;
345345
346346 trace_eq ("new" );
347347
348+ /* Check first before proceeding with dev and cd that coefficients
349+ * blob size is sane.
350+ */
351+ if (bs > SOF_EQ_IIR_MAX_SIZE ) {
352+ trace_eq_error ("ens" );
353+ trace_error_value (bs );
354+ return NULL ;
355+ }
356+
348357 dev = rzalloc (RZONE_RUNTIME , SOF_MEM_CAPS_RAM ,
349358 COMP_SIZE (struct sof_ipc_comp_eq_iir ));
350359 if (!dev )
@@ -365,15 +374,10 @@ static struct comp_dev *eq_iir_new(struct sof_ipc_comp *comp)
365374 cd -> iir_delay_size = 0 ;
366375 cd -> config = NULL ;
367376
368- bs = ipc_iir -> size ;
369- if (bs > SOF_EQ_IIR_MAX_SIZE ) {
370- rfree (dev );
371- rfree (cd );
372- return NULL ;
373- }
374-
375- /* Allocate and make a copy of the blob and setup IIR */
376- if (bs > 0 ) {
377+ /* Allocate and make a copy of the coefficients blob and reset IIR. If
378+ * the EQ is configured later in run-time the size is zero.
379+ */
380+ if (bs ) {
377381 cd -> config = rzalloc (RZONE_RUNTIME , SOF_MEM_CAPS_RAM , bs );
378382 if (!cd -> config ) {
379383 rfree (dev );
You can’t perform that action at this time.
0 commit comments