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] [day] [month] [year] [list]
Message-ID: <1ac834f698524ef8bce28a4a1024a3a7@AcuMS.aculab.com>
Date: Sat, 31 Aug 2024 12:27:19 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'Yan Zhen' <yanzhen@...o.com>, "han.xu@....com" <han.xu@....com>,
	"haibo.chen@....com" <haibo.chen@....com>, "broonie@...nel.org"
	<broonie@...nel.org>
CC: "yogeshgaur.83@...il.com" <yogeshgaur.83@...il.com>,
	"linux-spi@...r.kernel.org" <linux-spi@...r.kernel.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	"opensource.kernel@...o.com" <opensource.kernel@...o.com>
Subject: RE: [PATCH v2] spi: nxp-fspi: Use max macro

From: Yan Zhen
> Sent: 27 August 2024 14:12
> 
> When the original file is guaranteed to contain the minmax.h header file
> and compile correctly, using the real macro is usually
> more intuitive and readable.
> 
> Signed-off-by: Yan Zhen <yanzhen@...o.com>
> ---
> 
> Changes in v2:
> - Rewrite the subject.
> - Using max_t() instead of max().
> 
>  drivers/spi/spi-nxp-fspi.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/spi/spi-nxp-fspi.c b/drivers/spi/spi-nxp-fspi.c
> index 88397f712a3b..fda902aa5815 100644
> --- a/drivers/spi/spi-nxp-fspi.c
> +++ b/drivers/spi/spi-nxp-fspi.c
> @@ -756,8 +756,7 @@ static int nxp_fspi_read_ahb(struct nxp_fspi *f, const struct spi_mem_op *op)
>  			iounmap(f->ahb_addr);
> 
>  		f->memmap_start = start;
> -		f->memmap_len = len > NXP_FSPI_MIN_IOMAP ?
> -				len : NXP_FSPI_MIN_IOMAP;
> +		f->memmap_len = max_t(u32, len, NXP_FSPI_MIN_IOMAP);
> 

This shouldn't be max_t().
That is equivalent to:
		(u32)len > (u32)NXP_FSPI_MIN_IOMAP ? (u32)len) : (u32)NXP_FSPI_MIN_IOMAP;
Which you'd never write and has the obvious fubar that is 'len' is 64bit
and greater that 2^32 the wrong thing happens.

	David

>  		f->ahb_addr = ioremap(f->memmap_phy + f->memmap_start,
>  					 f->memmap_len);
> --
> 2.34.1
> 

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ