From: "Christian König" <christian.koenig@amd.com>
To: Bernard Zhao <bernard@vivo.com>,
Alex Deucher <alexander.deucher@amd.com>,
David Airlie <airlied@linux.ie>, Daniel Vetter <daniel@ffwll.ch>,
Monk Liu <Monk.Liu@amd.com>,
Hawking Zhang <Hawking.Zhang@amd.com>,
Yintian Tao <yttao@amd.com>, Dennis Li <Dennis.Li@amd.com>,
Wenhui Sheng <Wenhui.Sheng@amd.com>,
chen gong <curry.gong@amd.com>, Bokun Zhang <Bokun.Zhang@amd.com>,
"Stanley.Yang" <Stanley.Yang@amd.com>,
amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
linux-kernel@vger.kernel.org
Cc: opensource.kernel@vivo.com
Subject: Re: [PATCH] amd/amdgpu: use kmalloc_array to replace kmalloc with multiply
Date: Wed, 18 Nov 2020 09:17:49 +0100 [thread overview]
Message-ID: <f55ec782-9eff-c30b-2a0e-01a9898c9387@amd.com> (raw)
In-Reply-To: <20201118025503.102699-1-bernard@vivo.com>
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@vivo.com>
Not userspace controllable values, but looks cleaner anyway.
Reviewed-by: Christian König <christian.koenig@amd.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);
next prev parent reply other threads:[~2020-11-18 8:18 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-18 2:55 Bernard Zhao
2020-11-18 8:17 ` Christian König [this message]
2020-11-19 21:56 ` Alex Deucher
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f55ec782-9eff-c30b-2a0e-01a9898c9387@amd.com \
--to=christian.koenig@amd.com \
--cc=Bokun.Zhang@amd.com \
--cc=Dennis.Li@amd.com \
--cc=Hawking.Zhang@amd.com \
--cc=Monk.Liu@amd.com \
--cc=Stanley.Yang@amd.com \
--cc=Wenhui.Sheng@amd.com \
--cc=airlied@linux.ie \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=bernard@vivo.com \
--cc=curry.gong@amd.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=opensource.kernel@vivo.com \
--cc=yttao@amd.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®