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: <09929e85-badd-4c43-a7fa-cd27bf42fbb0@microchip.com>
Date: Thu, 27 Nov 2025 15:55:38 +0000
From: Prajna Rajendra Kumar <prajna.rajendrakumar@...rochip.com>
To: david laight <david.laight@...box.com>, Andy Shevchenko
	<andriy.shevchenko@...ux.intel.com>
CC: <linux-spi@...r.kernel.org>, <linux-kernel@...r.kernel.org>, Mark Brown
	<broonie@...nel.org>, Prajna Rajendra Kumar - M74368
	<prajna.rajendrakumar@...rochip.com>
Subject: Re: [PATCH v2 1/6] spi: microchip-core: use min() instead of min_t()

On 26/11/2025 09:22, david laight wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
>
> On Wed, 26 Nov 2025 08:54:39 +0100
> Andy Shevchenko <andriy.shevchenko@...ux.intel.com> wrote:
>
>> min_t(int, a, b) casts an 'unsigned int' to 'int'. This might lead
>> to the cases when big number is wrongly chosen. On the other hand,
>> the SPI transfer length is unsigned and driver uses signed type for
>> an unknown reason. Change the type of the transfer length to be
>> unsigned and convert use min() instead of min_t().
>>
>> Signed-off-by: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
> Reviewed-by: David Laight <david.laight.linux@...il.com>
Reviewed-by: Prajna Rajendra Kumar <prajna.rajendrakumar@...rochip.com>
>
>> ---
>>   drivers/spi/spi-microchip-core-spi.c | 10 +++++-----
>>   1 file changed, 5 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/spi/spi-microchip-core-spi.c b/drivers/spi/spi-microchip-core-spi.c
>> index 16e0885474a0..08ccdc5f0cc9 100644
>> --- a/drivers/spi/spi-microchip-core-spi.c
>> +++ b/drivers/spi/spi-microchip-core-spi.c
>> @@ -74,8 +74,8 @@ struct mchp_corespi {
>>        u8 *rx_buf;
>>        u32 clk_gen;
>>        int irq;
>> -     int tx_len;
>> -     int rx_len;
>> +     unsigned int tx_len;
>> +     unsigned int rx_len;
>>        u32 fifo_depth;
>>   };
>>
>> @@ -214,7 +214,7 @@ static irqreturn_t mchp_corespi_interrupt(int irq, void *dev_id)
>>                       spi->regs + MCHP_CORESPI_REG_INTCLEAR);
>>                finalise = true;
>>                dev_err(&host->dev,
>> -                     "RX OVERFLOW: rxlen: %d, txlen: %d\n",
>> +                     "RX OVERFLOW: rxlen: %u, txlen: %u\n",
>>                        spi->rx_len, spi->tx_len);
>>        }
>>
>> @@ -223,7 +223,7 @@ static irqreturn_t mchp_corespi_interrupt(int irq, void *dev_id)
>>                       spi->regs + MCHP_CORESPI_REG_INTCLEAR);
>>                finalise = true;
>>                dev_err(&host->dev,
>> -                     "TX UNDERFLOW: rxlen: %d, txlen: %d\n",
>> +                     "TX UNDERFLOW: rxlen: %u, txlen: %u\n",
>>                        spi->rx_len, spi->tx_len);
>>        }
>>
>> @@ -283,7 +283,7 @@ static int mchp_corespi_transfer_one(struct spi_controller *host,
>>        spi->rx_len = xfer->len;
>>
>>        while (spi->tx_len) {
>> -             int fifo_max = min_t(int, spi->tx_len, spi->fifo_depth);
>> +             unsigned int fifo_max = min(spi->tx_len, spi->fifo_depth);
>>
>>                mchp_corespi_write_fifo(spi, fifo_max);
>>                mchp_corespi_read_fifo(spi, fifo_max);



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ