From nobody Mon Jun 29 17:38:07 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6297AC433EF for ; Sat, 5 Feb 2022 17:38:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1380768AbiBERiH (ORCPT ); Sat, 5 Feb 2022 12:38:07 -0500 Received: from smtp08.smtpout.orange.fr ([80.12.242.130]:53649 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1380760AbiBERiG (ORCPT ); Sat, 5 Feb 2022 12:38:06 -0500 Received: from pop-os.home ([90.126.236.122]) by smtp.orange.fr with ESMTPA id GP0dngbZqxHdTGP0dnEjnn; Sat, 05 Feb 2022 18:38:04 +0100 X-ME-Helo: pop-os.home X-ME-Auth: YWZlNiIxYWMyZDliZWIzOTcwYTEyYzlhMmU3ZiQ1M2U2MzfzZDfyZTMxZTBkMTYyNDBjNDJlZmQ3ZQ== X-ME-Date: Sat, 05 Feb 2022 18:38:04 +0100 X-ME-IP: 90.126.236.122 From: Christophe JAILLET To: Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= , "Pan, Xinhui" , David Airlie , Daniel Vetter Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [PATCH] drm/radeon: Avoid open coded arithmetic in memory allocation Date: Sat, 5 Feb 2022 18:38:01 +0100 Message-Id: <1f44de96e6a49e912111fb3b664f087328b4c2cd.1644082664.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" kmalloc_array()/kcalloc() should be used to avoid potential overflow when a multiplication is needed to compute the size of the requested memory. So turn a kzalloc()+explicit size computation into an equivalent kcalloc(). Signed-off-by: Christophe JAILLET Reviewed-by: Christian K=C3=B6nig --- drivers/gpu/drm/radeon/radeon_atombios.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/radeon/radeon_atombios.c b/drivers/gpu/drm/rad= eon/radeon_atombios.c index 28c4413f4dc8..7b9cc7a9f42f 100644 --- a/drivers/gpu/drm/radeon/radeon_atombios.c +++ b/drivers/gpu/drm/radeon/radeon_atombios.c @@ -897,13 +897,13 @@ bool radeon_get_atom_connector_info_from_supported_de= vices_table(struct union atom_supported_devices *supported_devices; int i, j, max_device; struct bios_connector *bios_connectors; - size_t bc_size =3D sizeof(*bios_connectors) * ATOM_MAX_SUPPORTED_DEVICE; struct radeon_router router; =20 router.ddc_valid =3D false; router.cd_valid =3D false; =20 - bios_connectors =3D kzalloc(bc_size, GFP_KERNEL); + bios_connectors =3D kcalloc(ATOM_MAX_SUPPORTED_DEVICE, + sizeof(*bios_connectors), GFP_KERNEL); if (!bios_connectors) return false; =20 --=20 2.32.0