Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp18821pxb; Tue, 17 Nov 2020 18:57:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJyNJ2/ez3gZ8iUMw1/evVd7ML1XeVLFzUBjmwIqDc/GWtn5uDvNSbcg9sBIJqr9NMOzZMuI X-Received: by 2002:a05:6402:142f:: with SMTP id c15mr24256174edx.33.1605668239555; Tue, 17 Nov 2020 18:57:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605668239; cv=none; d=google.com; s=arc-20160816; b=GfLT82YHh5caCUDH7NqiA5pDKR1XRsWk1852rglda6Zb9ImcqVovhFNcOiNeDK4sKT UnqSfyLLKufJgPWjRQit5FB94M3xGh3aeyYcp9MrzXI+ozi4g+yCGWlB1LqLDw0Jveci EPrY1wUzEfpZB6aF+2TfRRVxxIbxN1N7IiC5oHZXMEhoYxYrcOsA8o3LJYz6JUeQQTc6 0BAjqFaPi4GrFf7j+1p3GDLcamn9DmB1IeQsGb8HznMFrOgCLmWPhfyyzatzvVlbDT9R 8NL40efKG6zDdjIRei2SCAeJmH+vcQK90oLPRcnOlygMBkJqUfR+VLXtVesuTmD5+ySB mE5g== 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=PCdn5iFxdQBpHqOOtrMOcA4dp77v8NeWYNrtXpS4Biw=; b=jYDaAa+xodUS/qPR9cckutLBHMrDvaSVASHvR2d3irV+Rrmr+2wFdqbC8x9SdToiFr 3xgJeKRGXazX3T0oycJstCJchZyQ0T1PjpxBFyd4kHNZwPgacpGRc5K4eBfe1YRlCy5e 9/yzg8EG3Yhv6g74FOmidXPC7aD04vv2tBl5qu/bQ5QPXLwXQFz8KFYff540AD1Sb4fe KMkZLa1UIv51hITPo4MYyKe12f3qqinBrgbiZSfGgrdMu050onQeoQJYHyKH74blHcWs QEejKpY1Jtk46d5dahq7w9eyC40oCe4N7nrq2BhKpqFa9DCPtLCYuKUGK4uuaHrRCb3E wJ1Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=vivo.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n2si2382404edi.362.2020.11.17.18.56.56; Tue, 17 Nov 2020 18:57:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=vivo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727200AbgKRCzP (ORCPT + 99 others); Tue, 17 Nov 2020 21:55:15 -0500 Received: from m17618.mail.qiye.163.com ([59.111.176.18]:16459 "EHLO m17618.mail.qiye.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726325AbgKRCzN (ORCPT ); Tue, 17 Nov 2020 21:55:13 -0500 Received: from ubuntu.localdomain (unknown [112.80.34.205]) by m17618.mail.qiye.163.com (Hmail) with ESMTPA id DD1734E16BE; Wed, 18 Nov 2020 10:55:09 +0800 (CST) From: Bernard Zhao To: Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= , David Airlie , Daniel Vetter , Monk Liu , Hawking Zhang , Yintian Tao , Dennis Li , Wenhui Sheng , chen gong , Bokun Zhang , "Stanley.Yang" , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: opensource.kernel@vivo.com, Bernard Zhao Subject: [PATCH] amd/amdgpu: use kmalloc_array to replace kmalloc with multiply Date: Tue, 17 Nov 2020 18:55:01 -0800 Message-Id: <20201118025503.102699-1-bernard@vivo.com> X-Mailer: git-send-email 2.29.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-HM-Spam-Status: e1kfGhgUHx5ZQUtXWQgYFAkeWUFZS1VLWVdZKFlBSE83V1ktWUFJV1kPCR oVCBIfWUFZHUxCS0geH0lCTEIfVkpNS05NTUNKSktPSEhVEwETFhoSFyQUDg9ZV1kWGg8SFR0UWU FZT0tIVUpKS09ISFVLWQY+ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6Nww6Kww6Kj8hKw8#SjI0Sy4Q TCNPFCpVSlVKTUtOTU1DSkpLQ05NVTMWGhIXVRkeCRUaCR87DRINFFUYFBZFWVdZEgtZQVlKSklV Q0tVSE9VSUtOWVdZCAFZQUlCTk43Bg++ X-HM-Tid: 0a75d946ff7f9376kuwsdd1734e16be Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Fix check_patch.pl warning: WARNING: Prefer kmalloc_array over kmalloc with multiply +bps = kmalloc(align_space * sizeof((*data)->bps), GFP_KERNEL); WARNING: Prefer kmalloc_array over kmalloc with multiply +bps_bo = kmalloc(align_space * sizeof((*data)->bps_bo), GFP_KERNEL); kmalloc_array has multiply overflow check, which will be safer. Signed-off-by: Bernard Zhao --- drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c index d0aea5e39531..f2a0851c804f 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c @@ -280,8 +280,8 @@ static int amdgpu_virt_init_ras_err_handler_data(struct amdgpu_device *adev) if (!*data) return -ENOMEM; - bps = kmalloc(align_space * sizeof((*data)->bps), GFP_KERNEL); - bps_bo = kmalloc(align_space * sizeof((*data)->bps_bo), GFP_KERNEL); + bps = kmalloc_array(align_space, sizeof((*data)->bps), GFP_KERNEL); + bps_bo = kmalloc_array(align_space, sizeof((*data)->bps_bo), GFP_KERNEL); if (!bps || !bps_bo) { kfree(bps); -- 2.29.0