From b0dc50b04445b378ad3da479b6d97328c03661a7 Mon Sep 17 00:00:00 2001
From: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Date: Mon, 9 Feb 2026 14:02:39 +0200
Subject: [PATCH 2/3] ASoC: SOF: ipc4-control: Set correct error code in
 refresh_bytes_control

Return -EINVAL in case the scontrol contains more data than the amount of
space available for it to store in sof_ipc4_refresh_bytes_control().

Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/linux-sound/aYXvFr-LVHVJSvS7@stanley.mountain/
Fixes: 2a28b5240f2b ("ASoC: SOF: ipc4-control: Add support for generic bytes control")
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Link: https://patch.msgid.link/20260209120239.6066-1-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
(cherry picked from commit f8f774913b4b599169381073f6674e20976e5529)
Signed-off-by: Chris Chiu <chris.chiu@canonical.com>
---
 sound/soc/sof/ipc4-control.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sound/soc/sof/ipc4-control.c b/sound/soc/sof/ipc4-control.c
index 06e441448be4..143cee248937 100644
--- a/sound/soc/sof/ipc4-control.c
+++ b/sound/soc/sof/ipc4-control.c
@@ -362,6 +362,7 @@ sof_ipc4_refresh_bytes_control(struct snd_sof_control *scontrol, bool lock)
 				"%s: no space for data in %s (%zu, %zu)\n",
 				__func__, scontrol->name, msg->data_size,
 				scontrol->max_size - sizeof(*data));
+			ret = -EINVAL;
 			goto out;
 		}
 
-- 
2.43.0

