[PATCH] ALSA: hda: Validate codec address in get_response
From: Sreeraj S Kurup
Date: Sat Dec 05 2026 - 04:38:23 EST
snd_hdac_bus_get_response() uses the codec address to access
the response array in the PIO and RIRB paths.
An invalid codec address can cause an out-of-bounds array
access. Add a check using snd_BUG_ON() and return -EINVAL
when the address is greater than or equal to HDA_MAX_CODECS.
This protects against invalid addresses passed by existing
callers as well as future callers, preventing access outside
the response array.
Signed-off-by: Sreeraj S Kurup <sreekuttan2156239@xxxxxxxxx>
---
sound/hda/core/controller.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/sound/hda/core/controller.c b/sound/hda/core/controller.c
index 3929dd195018..6f2baf3616ec 100644
--- a/sound/hda/core/controller.c
+++ b/sound/hda/core/controller.c
@@ -389,6 +389,10 @@ EXPORT_SYMBOL_GPL(snd_hdac_bus_send_cmd);
int snd_hdac_bus_get_response(struct hdac_bus *bus, unsigned int addr,
unsigned int *res)
{
+
+ if (snd_BUG_ON(addr >= HDA_MAX_CODECS))
+ return -EINVAL;
+
if (bus->use_pio_for_commands)
return snd_hdac_bus_get_response_pio(bus, addr, res);
--
2.55.0