[Sound-open-firmware] [PATCH] Component ABI: Check for valid ABI header for COMP_CMD_SET_DATA command

Seppo Ingalsuo seppo.ingalsuo at linux.intel.com
Mon Sep 25 15:12:59 CEST 2017


This patch adds the code to check the generic ABI header fields and reject
data with invalid header. The individual components those use ABI need
to check the component specific fields in addition.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo at linux.intel.com>
---
 src/include/reef/audio/component.h | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/src/include/reef/audio/component.h b/src/include/reef/audio/component.h
index 5ae8084..436a758 100644
--- a/src/include/reef/audio/component.h
+++ b/src/include/reef/audio/component.h
@@ -245,6 +245,17 @@ static inline int comp_host_buffer(struct comp_dev *dev,
 /* send component command - mandatory */
 static inline int comp_cmd(struct comp_dev *dev, int cmd, void *data)
 {
+	struct sof_ipc_ctrl_data *cdata = data;
+
+	if ((cmd == COMP_CMD_SET_DATA)
+		&& ((cdata->data->magic != SOF_ABI_MAGIC)
+		|| (cdata->data->abi != SOF_ABI_VERSION))) {
+		trace_comp_error("abi");
+		trace_value(cdata->data->magic);
+		trace_value(cdata->data->abi);
+		return -EINVAL;
+	}
+
 	return dev->drv->ops.cmd(dev, cmd, data);
 }
 
-- 
2.11.0



More information about the Sound-open-firmware mailing list