amd/amdgpu_ctx: Use struct_size() helper and kmalloc() (v2)
authorGustavo A. R. Silva <gustavoars@kernel.org>
Thu, 8 Oct 2020 14:34:50 +0000 (09:34 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 9 Oct 2020 18:44:39 +0000 (14:44 -0400)
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>
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c

index c80d833..a03398c 100644 (file)
@@ -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 = kzalloc(struct_size(entity, fences, amdgpu_sched_jobs),
                         GFP_KERNEL);
        if (!entity)
                return  -ENOMEM;