[PATCH 3/3] ASoC: Intel: avs: Prevent module info underflow

From: Cezary Rojewski

Date: Thu Oct 15 2026 - 14:57:26 EST


Typically modules information is first initialized when loading the base
AudioDSP base firmware and then expanded when loadable DSP modules are
requested by platform-components, see avs_component_load_libraries().

While theoretically not possible in a production scenario, there is no
reason to continue the IDAs preparation if an event caused the newly
obtained module information to be smaller or equal than the existing
information.

Fixes: c1a427e8da93 ("ASoC: Intel: avs: Firmware resources management utilities")
Signed-off-by: Cezary Rojewski <cezary.rojewski@xxxxxxxxx>
---
sound/soc/intel/avs/utils.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

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;
}

--
2.34.1