From 9f69c65d7b381fb0c67175b9b43747b51c44107f Mon Sep 17 00:00:00 2001 From: Jyri Sarha Date: Fri, 14 Jul 2023 12:31:36 +0300 Subject: [PATCH] ipc3: helper: Do not silently accept unrecognized component type in IPC 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 --- src/ipc/ipc3/helper.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/ipc/ipc3/helper.c b/src/ipc/ipc3/helper.c index 116571e13318..b83d8fb16be0 100644 --- a/src/ipc/ipc3/helper.c +++ b/src/ipc/ipc3/helper.c @@ -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; @@ -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) @@ -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");