All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ALSA: hda: intel: Validate master count before creating link mask
@ 2026-12-05 14:31 Sreeraj S Kurup
  2026-12-05 14:46 ` sashiko-bot
  2026-12-05 15:18 ` [PATCH v2] " Sreeraj S Kurup
  0 siblings, 2 replies; 3+ messages in thread
From: Sreeraj S Kurup @ 2026-12-05 14:31 UTC (permalink / raw)
  To: tiwai, perex; +Cc: linux-sound, linux-kernel, Sreeraj S Kurup

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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-12-05 15:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-05 14:31 [PATCH] ALSA: hda: intel: Validate master count before creating link mask Sreeraj S Kurup
2026-12-05 14:46 ` sashiko-bot
2026-12-05 15:18 ` [PATCH v2] " Sreeraj S Kurup

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.