summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Brown <broonie@kernel.org>2026-10-15 20:14:36 +0100
committerMark Brown <broonie@kernel.org>2026-10-15 20:14:36 +0100
commitb437bdbdd53fef57170e8ac939730cbfe8fa652f (patch)
treed23c89e4f22a052cb22ba5b6156bb6306187839f
parent56047769960a9eda5e60f659e1f1b8b777955eec (diff)
parent05c2975b4267246219e7aead0467626107e204e9 (diff)
ASoC: Intel: avs: Fix for recovery procedure and new size-checks
Cezary Rojewski <cezary.rojewski@intel.com> says: The first change addresses XRUN recovery for HDA-Link i.e.: BackEnd side of a HDAudio stream. It is the BE side equivalent of job done previously for FE side only with commit cfca1637bc2b ("ASoC: Intel: avs: Unprepare a stream when XRUN occurs") and its follow up titled: ("ASoC: Intel: avs: Reset the stream unless it is already prepared") [1]. The next fix problems found by static analyzers. Additional size checks for topology and a fix for module underflow should a DSP-module be unloaded on the DSP side in unexpected fashion. Theoretically that's not possible without a corrupted firmware, but the if-statement is already there, just a dev_warn() though. [1]: https://lore.kernel.org/linux-sound/20261010103753.16969-1-stiraspo@gmail.com/ Link: https://patch.msgid.link/20261015190240.729793-1-cezary.rojewski@intel.com
-rw-r--r--sound/soc/intel/avs/pcm.c2
-rw-r--r--sound/soc/intel/avs/topology.c6
-rw-r--r--sound/soc/intel/avs/utils.c6
3 files changed, 12 insertions, 2 deletions
diff --git a/sound/soc/intel/avs/pcm.c b/sound/soc/intel/avs/pcm.c
index 0d0881cb4699..f17bbc2ba63d 100644
--- a/sound/soc/intel/avs/pcm.c
+++ b/sound/soc/intel/avs/pcm.c
@@ -461,6 +461,8 @@ static int avs_dai_hda_be_prepare(struct snd_pcm_substream *substream, struct sn
link_stream = data->link_stream;
p = &be->dpcm[substream->stream].hw_params;
+ if (substream->runtime->state != SNDRV_PCM_STATE_PREPARED)
+ link_stream->link_prepared = false;
if (link_stream->link_prepared)
return 0;
diff --git a/sound/soc/intel/avs/topology.c b/sound/soc/intel/avs/topology.c
index 1085090d5a9c..e81401bb6dbd 100644
--- a/sound/soc/intel/avs/topology.c
+++ b/sound/soc/intel/avs/topology.c
@@ -1720,6 +1720,10 @@ static int avs_tplg_parse_initial_configs(struct snd_soc_component *comp,
AVS_TKN_INIT_CONFIG_ID_U32,
mod_init_config_parsers,
ARRAY_SIZE(mod_init_config_parsers));
+ if (ret)
+ return ret;
+ if (config->length > block_size)
+ return -EINVAL;
block_size -= esize;
@@ -1790,6 +1794,8 @@ static int avs_tplg_parse_nhlt_configs(struct snd_soc_component *comp,
/* With tuples parsed, the blob shall be allocated. */
if (!config->blob)
return -EINVAL;
+ if (config->blob->capabilities_size > block_size)
+ return -EINVAL;
/* Consume the raw data and move to the next entry. */
memcpy(config->blob->capabilities, (u8 *)tuples + esize,
diff --git a/sound/soc/intel/avs/utils.c b/sound/soc/intel/avs/utils.c
index ea14ec173855..f19a62e7e8b5 100644
--- a/sound/soc/intel/avs/utils.c
+++ b/sound/soc/intel/avs/utils.c
@@ -116,9 +116,11 @@ avs_module_ida_alloc(struct avs_dev *adev, struct avs_mods_info *newinfo, bool p
int i;
if (!purge && oldinfo) {
- if (oldinfo->count >= newinfo->count)
- dev_warn(adev->dev, "refreshing %d modules info with %d\n",
+ if (oldinfo->count >= newinfo->count) {
+ dev_warn(adev->dev, "modules info underflow, old: %d, new: %d\n",
oldinfo->count, newinfo->count);
+ return -EPROTO;
+ }
tocopy_count = oldinfo->count;
}