mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sreeraj S Kurup <sreekuttan2156239@gmail.com>
To: perex@perex.cz, tiwai@suse.de
Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
	Sreeraj S Kurup <sreekuttan2156239@gmail.com>
Subject: [PATCH] ALSA: hda: Validate codec address in get_response
Date: Sat,  5 Dec 2026 09:37:29 +0000	[thread overview]
Message-ID: <20261205093729.3271-1-sreekuttan2156239@gmail.com> (raw)

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@gmail.com>
---
 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


                 reply	other threads:[~2026-12-05  9:38 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261205093729.3271-1-sreekuttan2156239@gmail.com \
    --to=sreekuttan2156239@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=tiwai@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®