mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sreeraj S Kurup <sreekuttan2156239@gmail.com>
To: tiwai@suse.de, perex@perex.cz
Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
	Sreeraj S Kurup <sreekuttan2156239@gmail.com>
Subject: [PATCH] ALSA: hda: intel: Validate master count before creating link mask
Date: Sat,  5 Dec 2026 14:31:13 +0000	[thread overview]
Message-ID: <20261205143113.2888-1-sreekuttan2156239@gmail.com> (raw)

The driver uses GENMASK(count - 1, 0) to create the link
mask from the mipi-sdw-master-count ACPI property.

However, the count is checked only after GENMASK() is called.
If firmware reports a count of zero, the unsigned subtraction
count - 1 underflows. If the count exceeds
SDW_INTEL_MAX_LINKS, an invalid link mask may be generated.

Validate that the count is non-zero and does not exceed
SDW_INTEL_MAX_LINKS before creating the link mask.

Return -EINVAL if the count is invalid.

Signed-off-by: Sreeraj S Kurup <sreekuttan2156239@gmail.com>
---
 sound/hda/core/intel-sdw-acpi.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/sound/hda/core/intel-sdw-acpi.c b/sound/hda/core/intel-sdw-acpi.c
index d3511135f7d3..4d6bfc5e25de 100644
--- a/sound/hda/core/intel-sdw-acpi.c
+++ b/sound/hda/core/intel-sdw-acpi.c
@@ -90,6 +90,13 @@ sdw_intel_scan_controller(struct sdw_intel_acpi_info *info)
 				ret);
 			return ret;
 		}
+
+		/* Check count before constructing the link mask */
+		if (!count || count > SDW_INTEL_MAX_LINKS) {
+			dev_err(&adev->dev, "Invalid link count: %u\n",
+				count);
+			return -EINVAL;
+		}
 		list = GENMASK(count - 1, 0);
 	} else {
 		list = tmp;
-- 
2.55.0


             reply	other threads:[~2026-12-05 14:31 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-05 14:31 Sreeraj S Kurup [this message]
2026-12-05 15:18 ` [PATCH v2] " Sreeraj S Kurup
2026-12-06 11:09   ` Takashi Iwai

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=20261205143113.2888-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®