drm/amdgpu: Use struct_size() helper in kmalloc()
authorGustavo A. R. Silva <gustavoars@kernel.org>
Thu, 8 Oct 2020 14:23:05 +0000 (09:23 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 9 Oct 2020 18:43:30 +0000 (14:43 -0400)
Make use of the new struct_size() helper instead of the offsetof() idiom.

Reviewed-by: Christian König <christian.koenig@amd.com>
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_amdkfd_gpuvm.c

index b6b8215..c21f82c 100644 (file)
@@ -239,8 +239,7 @@ static int amdgpu_amdkfd_remove_eviction_fence(struct amdgpu_bo *bo,
        if (!old)
                return 0;
 
-       new = kmalloc(offsetof(typeof(*new), shared[old->shared_max]),
-                     GFP_KERNEL);
+       new = kmalloc(struct_size(new, shared, old->shared_max), GFP_KERNEL);
        if (!new)
                return -ENOMEM;