Skip to contentSkip to conversation

spi-rockchip: Fix register out of bounds access

PATCH New Vasiliy Kovalev 1 participant 1 message Oct 23, 2025 Stable branch

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 spi-rockchip: Fix register out of bounds access

From: Luis de Arquer <[email protected]>

commit 7a874e8b54ea21094f7fd2d428b164394c6cb316 upstream.

Do not write native chip select stuff for GPIO chip selects. GPIOs can be numbered much higher than native CS. Also, it makes no sense.

Fixes 736b81e07517 ("spi: rockchip: Support SPI_CS_HIGH")
[ kovalev: bp to fix CVE-2025-38081; added Fixes tag ]
---
 drivers/spi/spi-rockchip.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/spi/spi-rockchip.c +2 -2
index dbefc7e77313..cba858a7b4f9 100644
@@ -540,8 +540,8 @@ static int rockchip_spi_config(struct rockchip_spi *rs,
 	cr0 |= (spi->mode & 0x3U) << CR0_SCPH_OFFSET;
 	if (spi->mode & SPI_LSB_FIRST)
 		cr0 |= CR0_FBM_LSB << CR0_FBM_OFFSET;
-	if (spi->mode & SPI_CS_HIGH)
-		cr0 |= BIT(spi->chip_select) << CR0_SOI_OFFSET;
+	if ((spi->mode & SPI_CS_HIGH) && !(spi_get_csgpiod(spi, 0)))
+		cr0 |= BIT(spi_get_chipselect(spi, 0)) << CR0_SOI_OFFSET;
 
 	if (xfer->rx_buf && xfer->tx_buf)
 		cr0 |= CR0_XFM_TR << CR0_XFM_OFFSET;
Signature · 1 line
2.50.1