Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp2332891rdb; Mon, 12 Feb 2024 00:46:58 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUr3kUjZvQyN3phBNkU8Z6bWbs4KkwWmv/Gxq4NAdZbDR5jN1BUJn0vjFMpHfRz6DLaVelHwBrRN3JD4cWtFK9ZTqY0VuwzsmObmZtzNg== X-Google-Smtp-Source: AGHT+IGJuZcQFn4UCNw/bGpMgZ0qt5lDX+7KH7weQZ8ucQJBvSdjhA/Q/wVRgWBZ6D0oW62BDICy X-Received: by 2002:aa7:df01:0:b0:55f:fdd4:437b with SMTP id c1-20020aa7df01000000b0055ffdd4437bmr4340266edy.0.1707727617949; Mon, 12 Feb 2024 00:46:57 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707727617; cv=pass; d=google.com; s=arc-20160816; b=sTbfFGhJ+zymR3Sxv9f+iq6IzYfwZHyeZikaJ/ODGfn0w4RePu7vL68xbQrNAA4i0W sMI7xwVZpoJIyqph0AKS3EqSpoibCTuYKW40ScFtEWIxgFI55AhqCRkzGNv8bojo9h3a PY7nGmBfoYbhXy83BTSzYCqZoI9qeAg77DyNv5LWICzh7yPSppUpZIP30fENUSGvBdRn ZHP11mwawskxCoVpfyMWgFRE1XMT282a8ViHTBmOpNNUG2MGz0jGmO+G0JWCM34snyJA 8oP55itIuP1pSsO9c8/6b94FiBWg6cTtg2nU3q0A6qImhza4Hq4lBujZz4IMGXhkwTuH ieZg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=A08FGRKkKt+uuVMJDxB/G9R5NKV9T5oaUvubY5tIaUA=; fh=5eQR61h/g0wPiGEjT+IbUu39kr/hGiPqm7CXuHmUkzs=; b=ofkcJIy6s18A/EtPCzisO1grQjGrvElmRxIWsoAhjrwQhROqJ/mLEmfYO0s2J2TQBk HcvmcmiNgSjgE0jko/rGyJZsocFXgCK+p94Qakz/MxBycJqXqXJSdcNB1ic+IJWZwC6a RV8/Vgxn8SQO1ijVpcDWQyaEtyPfrwqnDGrz31ecy/BYf3ptOL6j1KBLMF0i+aFF8fKX ELY9LPPESbZea7yJv6ucv/xm2MBr9H7qQfeXNFBvtiprWEQHiiLVkwhgfhZB9y0dkLn1 5zXiOMT7grfRhrEaipDePa3Q6pJvJLXDmWIMjw0ymV8q57agk66kC0Fx/S8UEkVZ+xVv TRrg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=4QO9jfl5; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-61217-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61217-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com X-Forwarded-Encrypted: i=2; AJvYcCXHA1uRTXCP3s0VuwKcvhJj207yu/YuM+m99h5OYv2S0vNxX5P8P5tbKDLXyhbt66zNc+QSJcu4rqY/74cMWZEbdza0lAbrISs6vsEo5w== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id h21-20020a50cdd5000000b00561401f2877si2618231edj.34.2024.02.12.00.46.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 00:46:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-61217-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=4QO9jfl5; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-61217-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61217-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 87DD61F224ED for ; Mon, 12 Feb 2024 08:46:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B5040F9E6; Mon, 12 Feb 2024 08:46:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="4QO9jfl5" Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (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 64DB8F9CC; Mon, 12 Feb 2024 08:46:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707727607; cv=none; b=a9NPrtE+9CtjmW7pZA1TFEoVwhUYC8c+SL89aJvC/sHbFeiOiL8FZbgRbqCoMGqU4+WkAa2C/r6sED/rQZKuSOvWLN/RHPthSZKmUc/psX33mJu3ojeNBAA+ajGQfFPEezC2GFF6hBDkRQGej0QsJbfYRcGF5RmhJ/2btNE/4QA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707727607; c=relaxed/simple; bh=MrwKiPYRPkaUYKLWtoU0XksSmS1raWmw/40HvRZXI+g=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=keIFaQT4b/Cv9ApjVjxNVOauGN/HfOGZQF3u7r5fFgJYN5Wclt2lP4FcJD8wxAYpC79RnYcFCag+HjQpoViUHBAoesIfLgwhjS3JVtCmM9YThha5QL/TajGM+3yuamjMr07WQEIQJojoxSHitHxbvJZYCQ+5sRxbVftsgpoNCIw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=4QO9jfl5; arc=none smtp.client-ip=46.235.227.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1707727604; bh=MrwKiPYRPkaUYKLWtoU0XksSmS1raWmw/40HvRZXI+g=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=4QO9jfl5nZOSzTHkdnuCtf1s6Pj06nhsiAXE7a2JwM6wG6yLJvyI4oiQb8s5tzzEt uYf54+YYSy52QWb1hrPnh5qw5xnmE8+e5eWchvMXhmjmFnwV+x/E+IhyomZYAUy8Vy r2tlkwNhYhbCeX0WwgTvuyUprxjymuHjEYMSKyI1mxUPvjfxGxeAl+0paFHqi4W4fQ 7tx7FkBwzuG+BeJN10J6q5ngB+Y4YKzCckp9BokyqDYhJJvq+FXakWYx10NNAgzHj8 P93H/C06gnZz8bzZcZtiok2AXW1gxaDJWZ05tkBOu+4wRw5duVpM8UgdYQMKC5kWw5 2qwmFvE/2Uuaw== Received: from [100.113.186.2] (cola.collaboradmins.com [195.201.22.229]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: kholk11) by madrid.collaboradmins.com (Postfix) with ESMTPSA id 78C703782051; Mon, 12 Feb 2024 08:46:43 +0000 (UTC) Message-ID: Date: Mon, 12 Feb 2024 09:46:43 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] mtd: rawnand: Prefer struct_size over open coded arithmetic Content-Language: en-US To: Erick Archer , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Matthias Brugger , Martin Blumenstingl , Heiko Stuebner , =?UTF-8?Q?Philippe_Mathieu-Daud=C3=A9?= , Rob Herring , Li Zetao , =?UTF-8?Q?Uwe_Kleine-K=C3=B6nig?= , "Gustavo A. R. Silva" , Kees Cook Cc: 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 References: <20240211091633.4545-1-erick.archer@gmx.com> From: AngeloGioacchino Del Regno In-Reply-To: <20240211091633.4545-1-erick.archer@gmx.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Il 11/02/24 10:16, Erick Archer ha scritto: > 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 safer. > > 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 Just noticed that there was a v2 already addressing the commit description issue. Reviewed-by: AngeloGioacchino Del Regno