[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CADnq5_Pnv7+vu-mV3C5-zKXFexzs=qX6Jne6DKx-LteP_VQn-Q@mail.gmail.com>
Date: Thu, 19 Nov 2020 16:56:44 -0500
From: Alex Deucher <alexdeucher@...il.com>
To: Christian König <christian.koenig@....com>
Cc: Bernard Zhao <bernard@...o.com>,
Alex Deucher <alexander.deucher@....com>,
David Airlie <airlied@...ux.ie>,
Daniel Vetter <daniel@...ll.ch>, Monk Liu <Monk.Liu@....com>,
Hawking Zhang <Hawking.Zhang@....com>,
Yintian Tao <yttao@....com>, Dennis Li <Dennis.Li@....com>,
Wenhui Sheng <Wenhui.Sheng@....com>,
chen gong <curry.gong@....com>,
Bokun Zhang <Bokun.Zhang@....com>,
"Stanley.Yang" <Stanley.Yang@....com>,
amd-gfx list <amd-gfx@...ts.freedesktop.org>,
Maling list - DRI developers
<dri-devel@...ts.freedesktop.org>,
LKML <linux-kernel@...r.kernel.org>, opensource.kernel@...o.com
Subject: Re: [PATCH] amd/amdgpu: use kmalloc_array to replace kmalloc with multiply
Applied. Thanks!
Alex
On Wed, Nov 18, 2020 at 3:18 AM Christian König
<christian.koenig@....com> 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 = 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 <bernard@...o.com>
>
> Not userspace controllable values, but looks cleaner anyway.
>
> Reviewed-by: Christian König <christian.koenig@....com>
>
> > ---
> > 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);
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@...ts.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
Powered by blists - more mailing lists