[PATCH v2 0/2] ata: reject invalid DT port numbers in AHCI drivers
From: shao.mingyin
Date: Tue Nov 10 2026 - 10:58:46 EST
Both the shared AHCI platform support and the DWC glue use the "reg"
property of their port child nodes as a port number without checking
that it addresses one of the controller's ports.
Patch 1 is in the shared platform code. ahci_platform_get_firmware()
uses "reg" as an index into hpriv->saved_port_cap[] while filling the
firmware-specific port capabilities, so a "reg" value at or above
hpriv->nports writes past that array. Patch 2 is in the DWC glue.
ahci_dwc_init_dmacr() walks the same child nodes a second time and uses
"reg" both as an index into dpriv->dmacr[] and to compute the port MMIO
base, with the same out-of-range consequence.
Both loops now skip child nodes whose "reg" value is at or above
hpriv->nports, matching the check in ahci_platform_get_resources(),
which has already reported the invalid port number. The two patches
are independent and can be applied in any order; each carries Fixes:
and Cc: stable.
Changes in v2:
- Do not print a warning for an invalid port number: the resource loop
has already reported it (Niklas Cassel). The check is unchanged.
- Send the two fixes, previously posted separately, as one series at
Niklas's request.
- 2/2 keeps Damien Le Moal's Reviewed-by from v1, since the only change
is the dropped warning (confirmed by Niklas Cassel).
Link to v1 1/2: https://lore.kernel.org/all/20261029190111138tS0yRo0lL1zJZ_IutobE1@xxxxxxxxxx/
Link to v1 2/2: https://lore.kernel.org/all/20261104221318841yKO89PGcSNeaV4KutBOUJ@xxxxxxxxxx/
Review 1/2: https://lore.kernel.org/all/avHkMosHVOXCpVPD@ryzen/
Review 2/2: https://lore.kernel.org/all/avHknBRJnZPpAIke@ryzen/
Shao Mingyin (2):
ata: libahci_platform: reject invalid port numbers
ata: ahci_dwc: reject invalid DT port numbers
drivers/ata/ahci_dwc.c | 4 ++++
drivers/ata/libahci_platform.c | 4 ++++
2 files changed, 8 insertions(+)
---
base-commit: ddfe51b0a0f5dc9e415cc2c8ad8db17532dd426b