Re: [PATCH v2 06/10] spi: cadence-quadspi: Validate num-cs against CQSPI_MAX_CHIPSELECT

From: Théo Lebrun

Date: Fri Nov 27 2026 - 12:22:59 EST


Hello Lee,

On Fri Nov 27, 2026 at 4:31 PM CET, Lee Jones wrote:
> cqspi_of_get_pdata() reads cqspi->num_chipselect from the "num-cs"
> Device Tree property without checking that it fits within
> CQSPI_MAX_CHIPSELECT. cqspi_setup_flash() then validates each child
> node's chip select only against cqspi->num_chipselect before indexing
> cqspi->f_pdata[CQSPI_MAX_CHIPSELECT], allowing an out-of-bounds write
> if a DT specifies more than CQSPI_MAX_CHIPSELECT chip selects.
>
> Reject "num-cs" values exceeding CQSPI_MAX_CHIPSELECT in
> cqspi_of_get_pdata(), and store cs as u32 in cqspi_setup_flash() to
> match of_property_read_u32().
>
> Fixes: 0d62c64a8e48 ("spi: cadence-qspi: assert each subnode flash CS is valid")
> Closes: https://sashiko.dev/#/bug/linux-cd463fc8-1b94-4bcf-8d06-fae21b88894c
> Signed-off-by: Lee Jones <lee@xxxxxxxxxx>
> ---
> v1 => v2:
> - Reject num-cs values exceeding CQSPI_MAX_CHIPSELECT in
> cqspi_of_get_pdata() and store cs as u32 in cqspi_setup_flash(),
> per Theo Lebrun's review.
> - Simplify the commit message and drop the stable tag, per Theo
> Lebrun's review.
>
> drivers/spi/spi-cadence-quadspi.c | 12 +++++++++---
> 1 file changed, 9 insertions(+), 3 deletions(-)

Reviewed-by: Théo Lebrun <theo.lebrun@xxxxxxxxxxx>

Thanks,

--
Théo Lebrun, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com