lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <mafs0ms7ath3l.fsf@kernel.org>
Date: Thu, 04 Sep 2025 16:41:50 +0200
From: Pratyush Yadav <pratyush@...nel.org>
To: Santhosh Kumar K <s-k6@...com>
Cc: <miquel.raynal@...tlin.com>,  <broonie@...nel.org>,  <vigneshr@...com>,
  <marex@...x.de>,  <computersforpeace@...il.com>,
  <grmoore@...nsource.altera.com>,  <theo.lebrun@...tlin.com>,
  <linux-spi@...r.kernel.org>,  <linux-kernel@...r.kernel.org>,
  <praneeth@...com>,  <p-mantena@...com>,  <a-dutta@...com>,
  <u-kumar1@...com>
Subject: Re: [PATCH 3/4] spi: cadence-quadspi: Fix cqspi_setup_flash()

On Thu, Sep 04 2025, Santhosh Kumar K wrote:

> The 'max_cs' stores the largest chip select number. It should only
> be updated when the current 'cs' is greater than existing 'max_cs'. So,
> fix the condition accordingly.
>
> Fixes: 0f3841a5e115 ("spi: cadence-qspi: report correct number of chip-select")
> Signed-off-by: Santhosh Kumar K <s-k6@...com>
> ---
>  drivers/spi/spi-cadence-quadspi.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-quadspi.c
> index 447a32a08a93..da3ec15abb3e 100644
> --- a/drivers/spi/spi-cadence-quadspi.c
> +++ b/drivers/spi/spi-cadence-quadspi.c
> @@ -1722,7 +1722,7 @@ static const struct spi_controller_mem_caps cqspi_mem_caps = {
>  
>  static int cqspi_setup_flash(struct cqspi_st *cqspi)
>  {
> -	unsigned int max_cs = cqspi->num_chipselect - 1;
> +	unsigned int max_cs = 0;
>  	struct platform_device *pdev = cqspi->pdev;
>  	struct device *dev = &pdev->dev;
>  	struct cqspi_flash_pdata *f_pdata;
> @@ -1740,7 +1740,7 @@ static int cqspi_setup_flash(struct cqspi_st *cqspi)
>  		if (cs >= cqspi->num_chipselect) {
>  			dev_err(dev, "Chip select %d out of range.\n", cs);
>  			return -EINVAL;
> -		} else if (cs < max_cs) {
> +		} else if (cs > max_cs) {

Makes sense. Out of curiosity, are you using multiple CS in a real use
case or is this only theoretical?

Also nit: this could be simplified to:

		if (cs >= cqspi->num_chipselect) {
			dev_err(dev, "Chip select %d out of range.\n", cs);
			return -EINVAL;
		}

		max_cs = max_t(unsigned int, cs, max_cs);

but I think it is fine either way.

Reviewed-by: Pratyush Yadav <pratyush@...nel.org>

>  			max_cs = cs;
>  		}

-- 
Regards,
Pratyush Yadav

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ