Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp1619996rdb; Sat, 10 Feb 2024 09:23:28 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXPfQfTxNOoAJcBqw0/10ujOKkWCRBnaF6Ybt/vi269c5xiD0oj96a2AQin+YS+jhqyOEjmmp4Qqg1vkfXtQP6VmJpJ41wcYnVoUrK31A== X-Google-Smtp-Source: AGHT+IEC7Vom8naDwY4JcOeJeCOwYMfbRsKmBeNmh47nlo0kSSRIxP3odsXdXs2rpx3awbSJ5bNW X-Received: by 2002:a17:903:110e:b0:1d9:cc00:524c with SMTP id n14-20020a170903110e00b001d9cc00524cmr2675642plh.19.1707585808539; Sat, 10 Feb 2024 09:23:28 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707585808; cv=pass; d=google.com; s=arc-20160816; b=QFefUdqqGJ2+Pu45Jc8VfUnJvgCzGtbY5D7T8v3Q5Iweso1Tt9E7myuBOVMf/jDnOg GN0VyoNVOsRrPidZqytj4xc1amCyvrAO7IHg6ie4ZQPz/7R0xHUOPJTXuIoHPpcaQtZJ /fpN3rlR/1a0/RbJTY2nU23Agmd6/YPZrzFKpFInTc8EZBIdS6F/Ot1padsKN1bMAxep VzqTUz8Yjrr6g9qDzV4Dqq91dg2kdQEJK22pAOx8AeLH073kKEaAW6z42nnOkvZekEiS TMcuTuZGHFJgGcnhc5vb2ZgHjWkBJ/sz0WQFDsmoP0nFKaqL4GI9dsvKfH411qdmbn7o 9MYQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date; bh=KekJC1nQnNUKzHqhC3/yV5Jh7xIuCEBLPhsUlnW/8bk=; fh=y4tCM7NPHpKakR7qaBHkFGhLujjGgKH6gAOw2G5o43k=; b=VDH61CgjN2A6jdan8gsynNIq7zT6bPQvXta8Uko7Vo0DZUyQ96midaW7nvdvRYzcc0 tRWp7AURdzoNXzIv7RNoGfq0WaNTp2QZ687jwqB+oXwAeBW7HbG/02djDD6diA8gbCL3 q5jUe/83SHMbLjiHfPSvaPZ/+nQ3IrrqIuDaQL9gC5ZeOdOznWM+5QMCeLNdBp7dUK0L MgPZUgOCHFuNIPQI2NzdHrW6jaGfDSRNp9I4x3ZV4pWTcx5qYzkKGVZDGHgKcWKfsq/+ HxmdbiPpNTET+ys6MRKA8V7w5MYXlkMUJq/bAsuZhZwZ9Oi2nlGzsDTbHGfZ7ziDMmhY jV6A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-60498-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60498-linux.lists.archive=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCWvtccpVLVzJh7BANMk6M2SiH+/+b6wXGHQorU4k65xhtn8Makx/xdJ2vdDoRzWNNFBR1Xeg0a4uHSDoC0kSHJu358Afiu1ljk/48gNPg== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id me4-20020a170902fc4400b001d8a6dc0308si3755200plb.452.2024.02.10.09.23.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 09:23:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60498-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-60498-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60498-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 2EDE42813FB for ; Sat, 10 Feb 2024 17:23:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4DD525D460; Sat, 10 Feb 2024 17:23:12 +0000 (UTC) Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 407CD5CDEE for ; Sat, 10 Feb 2024 17:23:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707585791; cv=none; b=LUlq3h+dWvsYgt3r2CuVURrbrF1H4r6X02rcPSrW+9o1nkELBwMNLlAK94KEFn9zYY85HhRSocTOtrEdGJgQeNqZ3UdXkXGQszPFyMnRj1Ybnydn1L4PI35f6WzMRqj+yiV6PfSDZw3pCQIXa3WxATmx2ZbqonRZfL+lsZkS6u8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707585791; c=relaxed/simple; bh=3HOTMAvrmTBnH4wx3urQWmGfStLlmr/dw+Sp1ocasV0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=WFI6sAA0Mm4eLi5byVPNDhAIN45obbMiUh2cteD0eo1Sez4YDCFLL6RkDjyaN0D90QEqvYFSPm9M3at1dh7jxy5x+DIZ/F4SafalkplrdIMC77gupUfwv4KZRZEI2E1qsuAE17RYlSp54N7T+0ir+q1cLJHliu0dHqROWAB5lT0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rYr3s-0003V7-AK; Sat, 10 Feb 2024 18:22:44 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rYr3n-005icH-Po; Sat, 10 Feb 2024 18:22:39 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1rYr3n-002FSV-2F; Sat, 10 Feb 2024 18:22:39 +0100 Date: Sat, 10 Feb 2024 18:22:39 +0100 From: Uwe =?utf-8?Q?Kleine-K=C3=B6nig?= To: Erick Archer Cc: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Matthias Brugger , AngeloGioacchino Del Regno , Martin Blumenstingl , Heiko Stuebner , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Rob Herring , Li Zetao , "Gustavo A. R. Silva" , Kees Cook , linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH] mtd: rawnand: Prefer struct_size over open coded arithmetic Message-ID: References: <20240210161619.12656-1-erick.archer@gmx.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="346zxj37n4z5j2px" Content-Disposition: inline In-Reply-To: <20240210161619.12656-1-erick.archer@gmx.com> X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org --346zxj37n4z5j2px Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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]. >=20 > As the "chip" variable is a pointer to "struct mtk_nfc_nand_chip" and > this structure ends in a flexible array: >=20 > struct mtk_nfc_nand_chip { > [...] > u8 sels[] __counted_by(nsels); > }; >=20 > 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. >=20 > This way, the code is more readable and more safer. Unless you intend this non-English comparative: s/more safer/safer/ Best regards Uwe --=20 Pengutronix e.K. | Uwe Kleine-K=F6nig | Industrial Linux Solutions | https://www.pengutronix.de/ | --346zxj37n4z5j2px Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEP4GsaTp6HlmJrf7Tj4D7WH0S/k4FAmXHsN4ACgkQj4D7WH0S /k7uhggAkjErCNtMO9Tgeku9UEu3BBrTsCG6cirem2RU9oGOT4pbrCjRb2KCGYfU q+/lrPRkB6Tp8aLA3ljD5QZbmSN4UY7IFFRjTPhs2QeCfLX4USL2es+P4oCbd32u gZqw7aoZgZ1Gb05G5gboHeun8K3eEQE8eWfj1hq4BetoLNdq53tlW/csK98ayxPA JmPsBOXq5MHiGDSNqb1gp85oNS2F3D+F5YortaxkPr4F3L17MG9XDezixApG/nTw Uz2+EdFzM6BJN1Zac6t3Z2/6IaYa+aHE+ugdYp5aQIZ2NqiFaTHL7c9UfO85Zsi7 1fYuhJr1sBGrZoWF8QnOgiJmoDAtPA== =Sihr -----END PGP SIGNATURE----- --346zxj37n4z5j2px--