@@ -484,7 +484,7 @@ static struct comp_dev *eq_iir_new(struct sof_ipc_comp *comp)
484484 struct sof_ipc_comp_process * ipc_iir =
485485 (struct sof_ipc_comp_process * )comp ;
486486 size_t bs = ipc_iir -> size ;
487- int i ;
487+ int i , err ;
488488
489489 trace_eq ("eq_iir_new()" );
490490
@@ -506,8 +506,8 @@ static struct comp_dev *eq_iir_new(struct sof_ipc_comp *comp)
506506 COMP_SIZE (struct sof_ipc_comp_process ));
507507 if (!dev )
508508 return NULL ;
509-
510- memcpy ( & dev -> comp , comp , sizeof (struct sof_ipc_comp_process ));
509+ err = memcpy_s ( & dev -> comp , sizeof ( dev -> comp ),
510+ comp , sizeof (struct sof_ipc_comp_process ));
511511
512512 cd = rzalloc (RZONE_RUNTIME , SOF_MEM_CAPS_RAM , sizeof (* cd ));
513513 if (!cd ) {
@@ -532,8 +532,15 @@ static struct comp_dev *eq_iir_new(struct sof_ipc_comp *comp)
532532 rfree (cd );
533533 return NULL ;
534534 }
535+ err = memcpy_s (cd -> config , sizeof (* cd -> config ),
536+ ipc_iir -> data , bs );
537+ }
535538
536- memcpy (cd -> config , ipc_iir -> data , bs );
539+ if (err ) {
540+ trace_eq_error ("eq_iir_new() error: 0x%x" , err );
541+ rfree (dev );
542+ rfree (cd );
543+ return NULL ;
537544 }
538545
539546 for (i = 0 ; i < PLATFORM_MAX_CHANNELS ; i ++ )
@@ -584,7 +591,10 @@ static int iir_cmd_get_data(struct comp_dev *dev,
584591 if (bs > SOF_EQ_IIR_MAX_SIZE || bs == 0 ||
585592 bs > max_size )
586593 return - EINVAL ;
587- memcpy (cdata -> data -> data , cd -> config , bs );
594+ ret = memcpy_s (cdata -> data -> data ,
595+ ((struct sof_abi_hdr * )
596+ (cdata -> data ))-> size , cd -> config , bs );
597+
588598 cdata -> data -> abi = SOF_ABI_VERSION ;
589599 cdata -> data -> size = bs ;
590600 } else {
@@ -679,7 +689,10 @@ static int iir_cmd_set_data(struct comp_dev *dev,
679689 /* Just copy the configurate. The EQ will be initialized in
680690 * prepare().
681691 */
682- memcpy (cd -> config , cdata -> data -> data , bs );
692+
693+ ret = memcpy_s (cd -> config , sizeof (* cd -> config ),
694+ cdata -> data -> data , bs );
695+
683696 break ;
684697 default :
685698 trace_eq_error ("iir_cmd_set_data() error: invalid cdata->cmd" );
0 commit comments