[PATCH] ALSA: hda: intel: Validate master count before creating link mask
From: Sreeraj S Kurup
Date: Sat Dec 05 2026 - 09:31:57 EST
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@xxxxxxxxx>
---
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