]> www.infradead.org Git - users/hch/misc.git/commitdiff
drm/amd/display: change kzalloc to kcalloc in dml1_validate()
authorEthan Carter Edwards <ethan@ethancedwards.com>
Thu, 27 Feb 2025 23:16:24 +0000 (18:16 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 10 Mar 2025 17:36:17 +0000 (13:36 -0400)
We are trying to get rid of all multiplications from allocation
functions to prevent integer overflows. Here the multiplication is
probably safe, but using kcalloc() is more appropriate and improves
readability. This patch has no effect on runtime behavior.

Reviewed-by: Rodrigo Siqueira <siqueira@igalia.com>
Reviewed-by: Alex Hung <alex.hung@amd.com>
Signed-off-by: Ethan Carter Edwards <ethan@ethancedwards.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/dc/resource/dcn32/dcn32_resource.c

index 664302876019072a77b9330229f7fe8545787396..2a59cc61ed8c918a4b5beb1d90bf3a8f77fcdeb9 100644 (file)
@@ -1749,7 +1749,8 @@ static bool dml1_validate(struct dc *dc, struct dc_state *context, bool fast_val
 
        int vlevel = 0;
        int pipe_cnt = 0;
-       display_e2e_pipe_params_st *pipes = kzalloc(dc->res_pool->pipe_count * sizeof(display_e2e_pipe_params_st), GFP_KERNEL);
+       display_e2e_pipe_params_st *pipes = kcalloc(dc->res_pool->pipe_count,
+                       sizeof(display_e2e_pipe_params_st), GFP_KERNEL);
 
        /* To handle Freesync properly, setting FreeSync DML parameters
         * to its default state for the first stage of validation