Skip to content

Commit 5c018e3

Browse files
Luis de Arquerbroonie
authored andcommitted
spi: spi-rockchip: Fix out of bounds array access
Since spi-rockchip enables use_gpio_descriptors and the SPI_CONTROLLER_GPIO_SS flag, the spi subsytem may call set_cs() for spi devices with indexes above ROCKCHIP_SPI_MAX_CS_NUM Remove array cs_asserted[] which held a shadow copy of the state of the chip select lines with the only purpose of optimizing out rewriting a chip select line to the current state (no-op) This case is already handled by spi.c Signed-off-by: Luis de Arquer <luis.dearquer@inertim.com> Link: https://lore.kernel.org/r/d0a0c4b94f933f7f43973c34765214303ee82b77.camel@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 83c9c7e commit 5c018e3

File tree

1 file changed

+0
-8
lines changed

1 file changed

+0
-8
lines changed

drivers/spi/spi-rockchip.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,6 @@ struct rockchip_spi {
192192
u8 n_bytes;
193193
u8 rsd;
194194

195-
bool cs_asserted[ROCKCHIP_SPI_MAX_CS_NUM];
196-
197195
bool target_abort;
198196
bool cs_inactive; /* spi target tansmition stop when cs inactive */
199197
bool cs_high_supported; /* native CS supports active-high polarity */
@@ -245,10 +243,6 @@ static void rockchip_spi_set_cs(struct spi_device *spi, bool enable)
245243
struct rockchip_spi *rs = spi_controller_get_devdata(ctlr);
246244
bool cs_asserted = spi->mode & SPI_CS_HIGH ? enable : !enable;
247245

248-
/* Return immediately for no-op */
249-
if (cs_asserted == rs->cs_asserted[spi_get_chipselect(spi, 0)])
250-
return;
251-
252246
if (cs_asserted) {
253247
/* Keep things powered as long as CS is asserted */
254248
pm_runtime_get_sync(rs->dev);
@@ -268,8 +262,6 @@ static void rockchip_spi_set_cs(struct spi_device *spi, bool enable)
268262
/* Drop reference from when we first asserted CS */
269263
pm_runtime_put(rs->dev);
270264
}
271-
272-
rs->cs_asserted[spi_get_chipselect(spi, 0)] = cs_asserted;
273265
}
274266

275267
static void rockchip_spi_handle_err(struct spi_controller *ctlr,

0 commit comments

Comments
 (0)