From b31a8b652247f2c8c2933c61bd925f25637d0bd6 Mon Sep 17 00:00:00 2001 From: Johny Lin Date: Sun, 14 Apr 2024 05:12:18 +0000 Subject: [PATCH] module_adapter: return error if get_conf is not implemented At present, if get_configuration is not implemented by internal module, module_adapter will return 0 directly on config read commands. Under the circumstances, the host will suppose the reading is succeeded, but in fact the ata in IPC buffer is unwanted. This commit changes the return code to non-zero for such cases, which prevents the host getting the unwanted config data. Signed-off-by: Johny Lin --- src/audio/module_adapter/module_adapter_ipc3.c | 8 +++++++- src/audio/module_adapter/module_adapter_ipc4.c | 6 +++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/audio/module_adapter/module_adapter_ipc3.c b/src/audio/module_adapter/module_adapter_ipc3.c index 0f92ae7858ba..067920295795 100644 --- a/src/audio/module_adapter/module_adapter_ipc3.c +++ b/src/audio/module_adapter/module_adapter_ipc3.c @@ -207,7 +207,7 @@ static int module_adapter_get_set_params(struct comp_dev *dev, struct sof_ipc_ct comp_warn(dev, "module_adapter_get_set_params(): no configuration op set for %d", dev_comp_id(dev)); - return 0; + return -EIO; /* non-implemented error */ } static int module_adapter_ctrl_get_set_data(struct comp_dev *dev, struct sof_ipc_ctrl_data *cdata, @@ -272,6 +272,12 @@ int module_adapter_cmd(struct comp_dev *dev, int cmd, void *data, int max_data_s 0); break; case COMP_CMD_GET_VALUE: + /* + * Return error if getter is not implemented. Otherwise, the host will suppose + * the GET_VALUE command is successful, but the received cdata is not filled. + */ + ret = -EIO; + /* * IPC3 does not use config_id, so pass 0 for config ID as it will be ignored * anyway. Also, pass the 0 as the fragment size and data offset as they are not diff --git a/src/audio/module_adapter/module_adapter_ipc4.c b/src/audio/module_adapter/module_adapter_ipc4.c index 7ca28494af6a..884a57b419f5 100644 --- a/src/audio/module_adapter/module_adapter_ipc4.c +++ b/src/audio/module_adapter/module_adapter_ipc4.c @@ -159,7 +159,11 @@ int module_get_large_config(struct comp_dev *dev, uint32_t param_id, bool first_ if (interface->get_configuration) return interface->get_configuration(mod, param_id, data_offset_size, (uint8_t *)data, fragment_size); - return 0; + /* + * Return error if getter is not implemented. Otherwise, the host will suppose + * the GET_VALUE command is successful, but the received cdata is not filled. + */ + return -EIO; } EXPORT_SYMBOL(module_get_large_config);