[Sound-open-firmware] [PATCH v2 1/2] volume: check if ctrl cmd is for volume component

Ranjani Sridharan ranjani.sridharan at linux.intel.com
Tue Sep 12 14:54:52 CEST 2017


This patch adds a fix to check if the ctrl cmd is meant for the
volume component and if so, the data is valid.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan at linux.intel.com>
---
 src/audio/volume.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/src/audio/volume.c b/src/audio/volume.c
index 5808bed..363055d 100644
--- a/src/audio/volume.c
+++ b/src/audio/volume.c
@@ -385,6 +385,11 @@ static int volume_ctrl_set_cmd(struct comp_dev *dev, struct sof_ipc_ctrl_data *c
 	struct comp_data *cd = comp_get_drvdata(dev);
 	int i, j;
 
+	if (cdata == NULL) {
+		trace_volume_error("Sws");
+		return -EINVAL;
+	}
+
 	/* validate */
 	if (cdata->num_elems == 0 || cdata->num_elems >= SOF_IPC_MAX_CHANNELS) {
 		trace_volume_error("gs0");
@@ -436,6 +441,11 @@ static int volume_ctrl_get_cmd(struct comp_dev *dev, struct sof_ipc_ctrl_data *c
 	struct comp_data *cd = comp_get_drvdata(dev);
 	int i, j;
 
+	if (cdata == NULL) {
+		trace_volume_error("Swg");
+		return -EINVAL;
+	}
+
 	/* validate */
 	if (cdata->num_elems == 0 || cdata->num_elems >= SOF_IPC_MAX_CHANNELS) {
 		trace_volume_error("gc0");
@@ -469,6 +479,10 @@ static int volume_cmd(struct comp_dev *dev, int cmd, void *data)
 
 	trace_volume("cmd");
 
+	/* check if the ctrl cmd is for this component */
+	if ((cdata != NULL) && (cdata->comp_id != dev->comp.id))
+		return 0;
+
 	switch (cmd) {
 	case COMP_CMD_SET_VALUE:
 		return volume_ctrl_set_cmd(dev, cdata);
-- 
2.11.0



More information about the Sound-open-firmware mailing list