Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp790096pxb; Thu, 19 Nov 2020 13:59:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJzABywIoGVpxjPPULL7ijNX0D7/ljmtj5cigH7Vtb9/HkyY3TYVNos7Qr5vOAcQOGZX7yyu X-Received: by 2002:a17:906:5243:: with SMTP id y3mr9410413ejm.273.1605823158282; Thu, 19 Nov 2020 13:59:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605823158; cv=none; d=google.com; s=arc-20160816; b=j1DWtw7PM9H2E6GTaHsICEooJK09XLnlDH5IAJOU9mD4TkYbgpX9eC++JoniKG92jS l8EEu8yNVrL6/KCyojaVJPgaMGpORiaUIbhBNj4FxE5rqL9X6yOSuSbv4Rqvci4+w9hQ QrN8j20RcQoUwK0M/c+JjzVWKkJH7qNSRG5V8CcX+gICqjtc51QUmF2QHScRUsCJPY8K k3HKO5jD5rp99Yu4No92mZhboc6KVVGcQWOy3hzOLMftv0AhmSEOdy/4Hs0N75DflDOl 4gaRfimEo5uHsrur5fP7Y4h5h5LD0ypBhKXzwD28P/VofvXbrSRnmkxXPSx2UpyPc6++ jjVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=tlLqDfAGYn0nYJ3DEoNWqwPsD3d58ZqJLDR3pX/h9LI=; b=VkTFCZOEWRA4GU0E0VazjGTOxVYE/rscIBv7KogUYgVaL8RSvezXf/lDTqjT0iv1ay ahcPpQ/Xujutd5J25/jRR+2bMtfHBwiS8qtswTMThTcAWn/LMRXPXOYdx4/g/lkuF4Mw LQlGRlWSdBJ1oh6Qmn/oIlP9HutugwiSxgiRUDQyRXuNX2v3BaRxxabHiO/xaoPr5ty/ dpdg9wloRkc4He2FsrGdAzmuNp41GUQ69x644wHOvyKigpdxKNDhvN5QGn4HjZk6Alau ThacaorTKsqVkQSlbOQdZ23VspWk/IzQ2bGHpEIMZ+4DrAlrQRH1GZK759NermfL//Gn upDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=aaONIso3; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r9si576427ejc.144.2020.11.19.13.58.43; Thu, 19 Nov 2020 13:59:18 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=aaONIso3; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726590AbgKSV45 (ORCPT + 99 others); Thu, 19 Nov 2020 16:56:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726463AbgKSV45 (ORCPT ); Thu, 19 Nov 2020 16:56:57 -0500 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BA27C0613CF for ; Thu, 19 Nov 2020 13:56:57 -0800 (PST) Received: by mail-wm1-x342.google.com with SMTP id c198so6679399wmd.0 for ; Thu, 19 Nov 2020 13:56:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=tlLqDfAGYn0nYJ3DEoNWqwPsD3d58ZqJLDR3pX/h9LI=; b=aaONIso3P58VTJcyH558RGTSNI8DcgOx+J+A4s+NsJxRzoFR5feZMV3ZWp0qIxpL0Z SnP7g8Y3Fa/4igzONjn9VWSr8z244bjeVmZm1h9eMQb1Vo2nuTBZAsPOHvIi1bDeHEao iOWoCxnktaHRJYe67u94PIVWQkPIwA3/9B371y0tL7klgLfXBVdhUp4uKGxBLbMv54Dt n8GP1hegfYAd8ZN+z+tEjM/2VBuVL2mVuo96SMmmVElSmF7kKQutudcyiaB4cuSuazPX aq5RszqzGvaQO9rCOeo1PX+6BldMXzB4kxK29h2PYX7Vxhc0N6K0k2RzCLjLh03dVJ/m KTVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=tlLqDfAGYn0nYJ3DEoNWqwPsD3d58ZqJLDR3pX/h9LI=; b=aCqjhbnLQE0J877kPATvleM/MwUQWmwXHn/S4OsKffrDzt5xF4MZGpC1aXbGbQZzhp A5w0dKOElS8Ve6Lo/uSHXjYo226pRa7uJecaeEnNvQljAGbngzrgE8eONUUT6iNMecli E+J0vo7SNmHUowsQdS8LrpBhzzycjJg+XcbRVYr15G9ZviwBZSNRYj/lsAUQW3fohGzD Xgzh3luSVDPQApCf83t0PP5/l6DxMFWIKfy5dtPnPPWi4qYcEzcqEY1rshNXCwYuxFzz FLhxxhwUQSFT0ePM/V+RS009pBTs3atrg4KyrY7TB8YGylMXbjhbakiTi4Vy5fYktvnH mtkg== X-Gm-Message-State: AOAM530RyjsuC/7vr4WTq2xjuPdMG+js3vvXj4RsoSUl1P2ycwzOSO2N 99ZqGg7YhV4EHZY9ujdl4YdfkcRQWhYh0B444WU= X-Received: by 2002:a1c:1c3:: with SMTP id 186mr6576990wmb.39.1605823015772; Thu, 19 Nov 2020 13:56:55 -0800 (PST) MIME-Version: 1.0 References: <20201118025503.102699-1-bernard@vivo.com> In-Reply-To: From: Alex Deucher Date: Thu, 19 Nov 2020 16:56:44 -0500 Message-ID: Subject: Re: [PATCH] amd/amdgpu: use kmalloc_array to replace kmalloc with multiply To: =?UTF-8?Q?Christian_K=C3=B6nig?= Cc: Bernard Zhao , Alex Deucher , David Airlie , Daniel Vetter , Monk Liu , Hawking Zhang , Yintian Tao , Dennis Li , Wenhui Sheng , chen gong , Bokun Zhang , "Stanley.Yang" , amd-gfx list , Maling list - DRI developers , LKML , opensource.kernel@vivo.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Applied. Thanks! Alex On Wed, Nov 18, 2020 at 3:18 AM Christian K=C3=B6nig wrote: > > Am 18.11.20 um 03:55 schrieb Bernard Zhao: > > Fix check_patch.pl warning: > > WARNING: Prefer kmalloc_array over kmalloc with multiply > > +bps =3D kmalloc(align_space * sizeof((*data)->bps), GFP_KERNEL); > > WARNING: Prefer kmalloc_array over kmalloc with multiply > > +bps_bo =3D kmalloc(align_space * sizeof((*data)->bps_bo), > > GFP_KERNEL); > > kmalloc_array has multiply overflow check, which will be safer. > > > > Signed-off-by: Bernard Zhao > > Not userspace controllable values, but looks cleaner anyway. > > Reviewed-by: Christian K=C3=B6nig > > > --- > > 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(st= ruct amdgpu_device *adev) > > if (!*data) > > return -ENOMEM; > > > > - bps =3D kmalloc(align_space * sizeof((*data)->bps), GFP_KERNEL); > > - bps_bo =3D kmalloc(align_space * sizeof((*data)->bps_bo), GFP_KER= NEL); > > + bps =3D kmalloc_array(align_space, sizeof((*data)->bps), GFP_KERN= EL); > > + bps_bo =3D kmalloc_array(align_space, sizeof((*data)->bps_bo), GF= P_KERNEL); > > > > if (!bps || !bps_bo) { > > kfree(bps); > > _______________________________________________ > dri-devel mailing list > dri-devel@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/dri-devel