Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp1922353rdb; Sun, 11 Feb 2024 03:52:07 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVTylszFOZDRk5tG5IcoBODGBULVCpcNgcjQaT5iir7hOxPNlqhOeyf/vEWLnHwkGF5lK71yHXcF9Ly6FGiRUB9P9Tgb2Z4kHpsCuIeBw== X-Google-Smtp-Source: AGHT+IE54Vh4Bk2MJSPGukj80P3CNqiBVVIFzlXcR73mtDwwAkVpHiAIMSeSbvxtEJUM0y0AO4GO X-Received: by 2002:a05:6a20:d905:b0:19e:cea1:54a6 with SMTP id jd5-20020a056a20d90500b0019ecea154a6mr752506pzb.49.1707652326610; Sun, 11 Feb 2024 03:52:06 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707652326; cv=pass; d=google.com; s=arc-20160816; b=q0AE9A3tzpQD+tOPgGERc+U25+xoyoUQfbld/Qk1c2lfbgVAaxyO89wYuVwsyFyc6L FnOyuQ6iBS5JSe06k1zE0PnPRKHebKOT0iTyrMVwXA6UjxCVixhNUrZcZ/PDpXZMZyIx rIgHfYrWUKTQTwT6++X3IfkQ1l9dgM+sYsWCVYIHk/SoWN+9+DWM0gk3+I1GndoPU5dk JQ+RgZnBhMuaiXbPCmnwQQgQQ/sm7FrCY2G5ncGM9qt1Kv6zl4K9eeIVezLK//HXSqXs svnFkBzElZnJEKx2u01o///XrdoFAmnnWMfnc/8jc5kZ4sVRljiE5JU2e4fO+lIPBEyA vpfA== 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=jSHp3AIkMido/N1X4JGox0Dbv0/5+C2LK7HMFQ5+iqE=; fh=XEuZHQqRJmjwKDWCR/j3h8xVXAtjlvotTmvAioXA6Kc=; b=a5JUOgbwTQKAjGV5+qq3Sdi0OmlLNjaXq/OQ3Q6LWGjaVh9StNY2TLTUFLZUSfNw7P dPfWRfHeLXMBk4CRdAPVzpfT0X/bFtFkfHEaopBIZ9WXuxFoYnBdHRBR+U75beLRD4Wk ui0DRLTLZDUb4gXxKAYbvJkoXoFJ8ybb95jK0JjOMtS1pazOp0iMzZroAor4Btxcf9HG JFcQBOKsVlpiz5eCB9tkAnCHr5HCbuCDJMB0OxJElarYeDR5tRqJQ3Fc57tZUSOdGpIt DV/p2wU5QFSJxbm4UU1qPHYvc1RpKECMvTLnmzA6pRAwCtGHWnIumm3UHHZGG3149to9 lBjA==; 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-60720-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60720-linux.lists.archive=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCU7k9+6Ca1kjvzZ+EOfbHt0po8sQvS+9tuw3AW9tZRyHvjgT9/f0XJsvupk7LkXeG6gjRZYlEIeTgCOsWY0McgFTEjIJ4h/CLhgya5tHA== Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id i186-20020a6387c3000000b005dc352a5637si4651813pge.323.2024.02.11.03.52.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Feb 2024 03:52:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60720-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-60720-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60720-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 72B69B23293 for ; Sun, 11 Feb 2024 11:52:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6DD435A793; Sun, 11 Feb 2024 11:51:56 +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 8A5C042A94 for ; Sun, 11 Feb 2024 11:51:53 +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=1707652315; cv=none; b=sGt70fCmTDtcWkilgi486EOHdsnMN3UooIGO03uW7oVAReCqUxXhBBZ+mj1naa/qN03aXpkGyo7fU53TJG3RVvobkuruet2i/c6hy7Ht3SltwQGi6zq1Kc5cZ6o4sqJweRzpTMi5454hCXM5mORKjb3LJEh49x0d01WxWqfc5qI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707652315; c=relaxed/simple; bh=XOk8Kr8T8eOC+VVzgQLqdZmZkP4QeC0s2lWogs+CjA4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Z6zocXV9JlPpX/MNdwdVswQPvhlSRp3Y86T49YPg51YronzMpqmYPtZtIBvhrQc+87kbRG/Nk/e9aI0W5FaMWfXThK3142nFTHJxctCd9Z6B8pX0pX2+f3BazlprPO0FydMYrO2TqqAYXSstOJ3pvqOM5goXNzoq1BpnVMxNWsI= 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 1rZ8Mp-0000La-H1; Sun, 11 Feb 2024 12:51:27 +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 1rZ8Mj-0005Ea-EX; Sun, 11 Feb 2024 12:51:21 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1rZ8Mj-002Utq-17; Sun, 11 Feb 2024 12:51:21 +0100 Date: Sun, 11 Feb 2024 12:51:21 +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 v2] mtd: rawnand: Prefer struct_size over open coded arithmetic Message-ID: References: <20240211091633.4545-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="sfcqdcis3bm2zuuf" Content-Disposition: inline In-Reply-To: <20240211091633.4545-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 --sfcqdcis3bm2zuuf Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Feb 11, 2024 at 10:16:33AM +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 safer. >=20 > Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#open= -coded-arithmetic-in-allocator-arguments [1] > Link: https://github.com/KSPP/linux/issues/160 [2] > Reviewed-by: Gustavo A. R. Silva > Signed-off-by: Erick Archer Acked-by: Uwe Kleine-K=F6nig Best regards Uwe --=20 Pengutronix e.K. | Uwe Kleine-K=F6nig | Industrial Linux Solutions | https://www.pengutronix.de/ | --sfcqdcis3bm2zuuf Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEP4GsaTp6HlmJrf7Tj4D7WH0S/k4FAmXItLgACgkQj4D7WH0S /k5ikgf9F4/qTgtnox96aTKRccDzsaTgOw9Qi3pN71OjgluyHYlBZZuLkP5oxvMH 1xtEtrRoArhwg8s5AISfkCSKbJG6D3uSXUf9HsjiHx2K2tK+RkQy1vFalheaw7V5 E4xeT2nxo6jpRzzqeqs75p8KbDE1FdrEZZuarr3wqtfb+oapvNF8Fy9a82Yg1BZC DMVilJ/dMLxb6nLJ6V0fGGOzzio9S8AIFx0alMWvEzVu8i+yDDLBWbQDlQZTqzIn lfNs4OCNwrzqhNhlWD6V8lzYV8SaUtFW+1A6ZKJb19MwobAnXElAgIQJOWX0PSY1 vASWpbUmeY9zm+JPlBvqvX/3KIcWew== =DQCU -----END PGP SIGNATURE----- --sfcqdcis3bm2zuuf--