amd/amdgpu_ctx: Use struct_size() helper and kmalloc() (v2)

Make use of the new struct_size() helper instead of the offsetof() idiom.
Also, use kmalloc() instead of kcalloc().

v2: squash in kzalloc fix

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
Gustavo A. R. Silva 2020-10-08 09:34:50 -05:00 committed by Alex Deucher
parent 562f150fb9
commit 201a4eb9dc
1 changed files with 1 additions and 1 deletions

View File

@ -100,7 +100,7 @@ static int amdgpu_ctx_init_entity(struct amdgpu_ctx *ctx, u32 hw_ip,
enum drm_sched_priority priority; enum drm_sched_priority priority;
int r; int r;
entity = kcalloc(1, offsetof(typeof(*entity), fences[amdgpu_sched_jobs]), entity = kzalloc(struct_size(entity, fences, amdgpu_sched_jobs),
GFP_KERNEL); GFP_KERNEL);
if (!entity) if (!entity)
return -ENOMEM; return -ENOMEM;