Skip to content

Commit

Permalink
ipc3: helper: Do not silently accept unrecognized component type in IPC
Browse files Browse the repository at this point in the history
Return an error code from comp_specific_builder() if the component
type is not recognized, instead of just silently ignoring the error.

Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
  • Loading branch information
Jyri Sarha authored and kv2019i committed Jul 17, 2023
1 parent be2c2fc commit 21ed10a
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/ipc/ipc3/helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ union ipc_config_specific {
} __attribute__((packed, aligned(4)));

/* build component specific data */
static void comp_specific_builder(struct sof_ipc_comp *comp,
union ipc_config_specific *config)
static int comp_specific_builder(struct sof_ipc_comp *comp,
union ipc_config_specific *config)
{
#if CONFIG_LIBRARY
struct sof_ipc_comp_file *file = (struct sof_ipc_comp_file *)comp;
Expand Down Expand Up @@ -285,8 +285,9 @@ static void comp_specific_builder(struct sof_ipc_comp *comp,
#endif
break;
default:
break;
return -EINVAL;
}
return 0;
}

struct ipc_comp_dev *ipc_get_comp_by_ppl_id(struct ipc *ipc, uint16_t type, uint32_t ppl_id)
Expand Down Expand Up @@ -328,8 +329,11 @@ struct comp_dev *comp_new(struct sof_ipc_comp *comp)
drv->tctx->uuid_p, comp->type, comp->pipeline_id, comp->id);

/* build the component */
if (comp_specific_builder(comp, &spec) < 0) {
comp_cl_err(drv, "comp_new(): component type not recognized");
return NULL;
}
comp_common_builder(comp, &config);
comp_specific_builder(comp, &spec);
cdev = drv->ops.create(drv, &config, &spec);
if (!cdev) {
comp_cl_err(drv, "comp_new(): unable to create the new component");
Expand Down

0 comments on commit 21ed10a

Please sign in to comment.