drm/amd/display: use kcalloc instead of open coded arithmetic
Subsystems (3)
PATCH 1/1 drm/amd/display: use kcalloc instead of open coded arithmetic
From: Yang Guang <[email protected]>
Dynamic size calculations (especially multiplication) should not be performed in memory allocator (or similar) function arguments due to the risk of them overflowing. This could lead to values wrapping around and a smaller allocation being made than the caller was expecting. Using those allocations could lead to linear overflows of heap memory and other misbehaviors.
Signed-off-by Chen Haonan <[email protected]>
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1 -1
@@ -9204,7 +9204,7 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)* Here we create an empty update on each plane. * To fix this, DC should permit updating only stream properties. */ - dummy_updates =kzalloc (sizeof (struct dc_surface_update ) *MAX_SURFACES ,GFP_ATOMIC ); + dummy_updates =kcalloc (MAX_SURFACES ,sizeof (struct dc_surface_update ),GFP_ATOMIC );for (j =0 ; j < status->plane_count; j++) dummy_updates[j].surface = status->plane_states[0 ];
Signature · 1 line
2.25.1