Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp5189177pxb; Sun, 6 Feb 2022 17:04:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJyr/ZEzU8ugHxhYijUIHZNJGj60spgc929aolyqxoqS/tpO2YZyPYvVftITeOaVYZqhnVLt X-Received: by 2002:a17:90b:3503:: with SMTP id ls3mr11307210pjb.190.1644195891465; Sun, 06 Feb 2022 17:04:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644195891; cv=none; d=google.com; s=arc-20160816; b=mFttKEVUsMgZ6fFrp1xGdqJtzX2ElKkoJKafYVLwdOa+WI5n95NaEPhO+2QGtkFvZW 1YkNWl6/2gDH0a2xLi+SG5fcQyuqV89DqbRq5p0gL6bfOE56Gs0DQRcEAupB2ubkB+9w VAf7sErXeRebt6XWejQap3/T2urgstqtEESd6aAEwIGG5bh56rYkf9XXuc4/tn8JdicB cZ+DKim6i+exlF2MRko3mH4Y/sMeEwOxitsrwk/8gTeKMviES/t45wcv9l1AtDJaE44l 7jhwFYFje2SD88TF6dKbOv+nR7AVDRC0c1oMEKMakv59l1lfkThsv9amcqd06YdOwGkI C0gg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=+v//H1HLgQZzcRswL0QIgwKXCRHTyyxfY78jjaAtKig=; b=FN3qK5ydw3sTyT5kQBGCjN161UmQAtiMI5Q9zCUBJuCK8iJscrcW9dBzdc9Kj0kIEy vGRH1VFPqWnh1F9/05xuGXajxeJjhAVLTjYeIk8Y+2zmF2HOHkP9Ov0zEdfdPfynctFs wX98JaS3Gl00v/osEBYbwiozQ+52rfnavJ4vb04SLc0zQMqEE1YI980oQ1mf+P91dUrz tDZXtxSUXkYNOr7i4rYFGh/9/XySTdzAPO9qhEyGSWm8xNdSGaFjAjuIUdYLk+EO32qV x9L3hUEmeDxjeu22ahZyv73wXlFREiUQwOU+Fz1ggZgiM7CeNnbT9JH75SPqsTrpW6pG 5V5w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x2si7979329pll.296.2022.02.06.17.04.11; Sun, 06 Feb 2022 17:04:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1380766AbiBERiH (ORCPT + 99 others); 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: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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/radeon/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_devices_table(struct union atom_supported_devices *supported_devices; int i, j, max_device; struct bios_connector *bios_connectors; - size_t bc_size = sizeof(*bios_connectors) * ATOM_MAX_SUPPORTED_DEVICE; struct radeon_router router; router.ddc_valid = false; router.cd_valid = false; - bios_connectors = kzalloc(bc_size, GFP_KERNEL); + bios_connectors = kcalloc(ATOM_MAX_SUPPORTED_DEVICE, + sizeof(*bios_connectors), GFP_KERNEL); if (!bios_connectors) return false; -- 2.32.0