[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <vm3fk7wbqxjl3i6kmd3dv2ofeszjxrvi2n7cd3ohasgjpi4j4g@d3f6estk2xol>
Date: Sat, 10 Feb 2024 18:22:39 +0100
From: Uwe Kleine-König <u.kleine-koenig@...gutronix.de>
To: Erick Archer <erick.archer@....com>
Cc: Miquel Raynal <miquel.raynal@...tlin.com>,
Richard Weinberger <richard@....at>, Vignesh Raghavendra <vigneshr@...com>,
Matthias Brugger <matthias.bgg@...il.com>,
AngeloGioacchino Del Regno <angelogioacchino.delregno@...labora.com>, Martin Blumenstingl <martin.blumenstingl@...glemail.com>,
Heiko Stuebner <heiko@...ech.de>, Philippe Mathieu-Daudé <philmd@...aro.org>,
Rob Herring <robh@...nel.org>, Li Zetao <lizetao1@...wei.com>,
"Gustavo A. R. Silva" <gustavoars@...nel.org>, Kees Cook <keescook@...omium.org>, linux-mtd@...ts.infradead.org,
linux-kernel@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
linux-mediatek@...ts.infradead.org, linux-hardening@...r.kernel.org
Subject: Re: [PATCH] mtd: rawnand: Prefer struct_size over open coded
arithmetic
On Sat, Feb 10, 2024 at 05:16:19PM +0100, Erick Archer wrote:
> This is an effort to get rid of all multiplications from allocation
> functions in order to prevent integer overflows [1].
>
> As the "chip" variable is a pointer to "struct mtk_nfc_nand_chip" and
> this structure ends in a flexible array:
>
> struct mtk_nfc_nand_chip {
> [...]
> u8 sels[] __counted_by(nsels);
> };
>
> the preferred way in the kernel is to use the struct_size() helper to
> do the arithmetic instead of the argument "size + count * size" in the
> devm_kzalloc() function.
>
> This way, the code is more readable and more safer.
Unless you intend this non-English comparative: s/more safer/safer/
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | https://www.pengutronix.de/ |
Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)
Powered by blists - more mailing lists