drm/amdgpu: Use struct_size() helper in kmalloc()
Subsystems (3)
PATCH 1/1 drm/amdgpu: Use struct_size() helper in kmalloc()
Make use of the new struct_size() helper instead of the offsetof() idiom.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +1 -2
@@ -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 ;
Signature · 1 line
2.27.0
Alex Deucher
AppliedApplied. Thanks!
Alex
Quoted 25 lines · Gustavo A. R. Silva
Make use of the new
struct_size()helper instead of theoffsetof()idiom.Signed-off-by Gustavo A. R. Silva <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +1
-3@@ -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 ; --2.27.0
Quoted 4 lines
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Am 08.10.20 um 16:23 schrieb Gustavo A. R. Silva:
Quoted 3 lines
Make use of the new
struct_size()helper instead of theoffsetof()idiom.Signed-off-by Gustavo A. R. Silva <[email protected]>
Quoted 9 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c static int amdgpu_amdkfd_remove_eviction_fence(struct amdgpu_bo *bo, · line 245
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +1
-2@@ -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 ;
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx