From: Gustavo A. R. Silva Date: Thu, 8 Oct 2020 14:23:05 +0000 (-0500) Subject: drm/amdgpu: Use struct_size() helper in kmalloc() X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=562f150fb93b44884f467f531b18cb0b8fdb2ff4;p=linux.git drm/amdgpu: Use struct_size() helper in kmalloc() Make use of the new struct_size() helper instead of the offsetof() idiom. Reviewed-by: Christian König Signed-off-by: Gustavo A. R. Silva Signed-off-by: Alex Deucher --- diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c index b6b821500d30a..c21f82c959221 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c @@ -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;