From: "Christian König" <christian.koenig@amd.com>
To: "Gustavo A. R. Silva" <gustavoars@kernel.org>,
Alex Deucher <alexander.deucher@amd.com>,
David Airlie <airlied@linux.ie>, Daniel Vetter <daniel@ffwll.ch>
Cc: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org
Subject: Re: [PATCH][next] amd/amdgpu_ctx: Use struct_size() helper and kmalloc()
Date: Fri, 9 Oct 2020 09:08:51 +0200 [thread overview]
Message-ID: <4fe00048-2612-39f3-29bb-c9424000f836@amd.com> (raw)
In-Reply-To: <20201008143450.GA23077@embeddedor>
Am 08.10.20 um 16:34 schrieb Gustavo A. R. Silva:
> Make use of the new struct_size() helper instead of the offsetof() idiom.
> Also, use kmalloc() instead of kcalloc().
>
> Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
> index c80d8339f58c..5be125f3b92a 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
> @@ -100,7 +100,7 @@ static int amdgpu_ctx_init_entity(struct amdgpu_ctx *ctx, u32 hw_ip,
> enum drm_sched_priority priority;
> int r;
>
> - entity = kcalloc(1, offsetof(typeof(*entity), fences[amdgpu_sched_jobs]),
> + entity = kmalloc(struct_size(entity, fences, amdgpu_sched_jobs),
NAK. You could use kzalloc() here, but kmalloc won't zero initialize the
memory which could result in unforeseen consequences.
Christian.
> GFP_KERNEL);
> if (!entity)
> return -ENOMEM;
next prev parent reply other threads:[~2020-10-09 7:09 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-08 14:34 [PATCH][next] amd/amdgpu_ctx: Use struct_size() helper and kmalloc() Gustavo A. R. Silva
2020-10-08 17:22 ` Alex Deucher
2020-10-09 7:08 ` Christian König [this message]
2020-10-09 13:54 ` Gustavo A. R. Silva
2020-10-09 14:29 ` Christian König
2020-10-09 14:39 ` Gustavo A. R. Silva
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=4fe00048-2612-39f3-29bb-c9424000f836@amd.com \
--to=christian.koenig@amd.com \
--cc=airlied@linux.ie \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=gustavoars@kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).