drm/amd/display: move from kzalloc(size * nr, ...) to kcalloc(nr, size, ...)
Subsystems (3)
cover drm/amd/display: move from kzalloc(size * nr, ...) to kcalloc(nr, size, ...)
We are trying to get rid of all multiplications from allocation functions to prevent integer overflows. Here the multiplications are probably safe, but using kcalloc() is more appropriate and improves readability. It is also safer. This series contains a few patches with these fixes.
Part of the Kernel Self Protection Project efforts. Links below have more details.
---
Ethan Carter Edwards (4):
drm/amd/display: change kzalloc to kcalloc in dcn30_validate_bandwidth() drm/amd/display: change kzalloc to kcalloc in dcn31_validate_bandwidth() drm/amd/display: change kzalloc to kcalloc in dcn314_validate_bandwidth() drm/amd/display: change kzalloc to kcalloc in dml1_validate()
drivers/gpu/drm/amd/display/dc/resource/dcn30/dcn30_resource.c | 3 ++- drivers/gpu/drm/amd/display/dc/resource/dcn31/dcn31_resource.c | 3 ++- drivers/gpu/drm/amd/display/dc/resource/dcn314/dcn314_resource.c | 3 ++- drivers/gpu/drm/amd/display/dc/resource/dcn32/dcn32_resource.c | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-)
---
base-commit: be5c7bbb3a64baf884481a1ba0c2f8fb2f93f7c3
change-id: 20250227-amd-display-a8342c55a9a0
Best regards,
Signature · 1 line
Ethan Carter Edwards <[email protected]>
PATCH 1/4 drm/amd/display: change kzalloc to kcalloc in dcn30_validate_bandwidth()
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.
--- drivers/gpu/drm/amd/display/dc/resource/dcn30/dcn30_resource.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/resource/dcn30/dcn30_resource.c +2 -1
@@ -2047,7 +2047,8 @@ bool dcn30_validate_bandwidth(struct dc *dc,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 );DC_LOGGER_INIT (dc->ctx->logger);BW_VAL_TRACE_COUNT ();
Signature · 1 line
2.48.1
PATCH 2/4 drm/amd/display: change kzalloc to kcalloc in dcn31_validate_bandwidth()
In reply to Ethan Carter EdwardsWe 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.
--- drivers/gpu/drm/amd/display/dc/resource/dcn31/dcn31_resource.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/resource/dcn31/dcn31_resource.c +2 -1
@@ -1768,7 +1768,8 @@ bool dcn31_validate_bandwidth(struct dc *dc,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 );DC_LOGGER_INIT (dc->ctx->logger);BW_VAL_TRACE_COUNT ();
Signature · 1 line
2.48.1
PATCH 3/4 drm/amd/display: change kzalloc to kcalloc in dcn314_validate_bandwidth()
In reply to Ethan Carter EdwardsWe 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.
--- drivers/gpu/drm/amd/display/dc/resource/dcn314/dcn314_resource.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/resource/dcn314/dcn314_resource.c +2 -1
@@ -1704,7 +1704,8 @@ bool dcn314_validate_bandwidth(struct dc *dc,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 );DC_LOGGER_INIT (dc->ctx->logger);BW_VAL_TRACE_COUNT ();
Signature · 1 line
2.48.1
PATCH 4/4 drm/amd/display: change kzalloc to kcalloc in dml1_validate()
In reply to Ethan Carter EdwardsWe 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.
--- drivers/gpu/drm/amd/display/dc/resource/dcn32/dcn32_resource.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/resource/dcn32/dcn32_resource.c +2 -1
@@ -1749,7 +1749,8 @@ static bool dml1_validate(struct dc *dc, struct dc_state *context, bool fast_valint 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
Signature · 1 line
2.48.1
Quoted 25 lines · Ethan Carter Edwards
We are trying to get rid of all multiplications from allocation functions to prevent integer overflows. Here the multiplications are probably safe, but using
kcalloc()is more appropriate and improves readability. It is also safer. This series contains a few patches with these fixes.Part of the Kernel Self Protection Project efforts. Links below have more details.
Signed-off-by Ethan Carter Edwards <[email protected]>---
Ethan Carter Edwards (4):
drm/amd/display: change kzalloc to kcalloc indcn30_validate_bandwidth()drm/amd/display: change kzalloc to kcalloc indcn31_validate_bandwidth()drm/amd/display: change kzalloc to kcalloc indcn314_validate_bandwidth()drm/amd/display: change kzalloc to kcalloc indml1_validate()drivers/gpu/drm/amd/display/dc/resource/dcn30/dcn30_resource.c | 3 ++- drivers/gpu/drm/amd/display/dc/resource/dcn31/dcn31_resource.c | 3 ++- drivers/gpu/drm/amd/display/dc/resource/dcn314/dcn314_resource.c | 3 ++- drivers/gpu/drm/amd/display/dc/resource/dcn32/dcn32_resource.c | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-)
Quoted 8 lines
---
base-commit:be5c7bbb3a64baf884481a1ba0c2f8fb2f93f7c3
change-id: 20250227-amd-display-a8342c55a9a0Best regards,
Signature · 1 line
Ethan Carter Edwards <[email protected]>
Hi,
This series LGTM,
To Display folks,
(Cc some other devs)
If possible, try to include this series in this week's promotion tests, or check the IGT test in the CI just to be safe.
Thanks
Signature · 1 line
Rodrigo Siqueira
This series LGTM too.
Quoted 30 lines · Ethan Carter Edwards
We are trying to get rid of all multiplications from allocation functions to prevent integer overflows. Here the multiplications are probably safe, but using
kcalloc()is more appropriate and improves readability. It is also safer. This series contains a few patches with these fixes.Part of the Kernel Self Protection Project efforts. Links below have more details.
Signed-off-by Ethan Carter Edwards <[email protected]>---
Ethan Carter Edwards (4):
drm/amd/display: change kzalloc to kcalloc indcn30_validate_bandwidth()drm/amd/display: change kzalloc to kcalloc indcn31_validate_bandwidth()drm/amd/display: change kzalloc to kcalloc indcn314_validate_bandwidth()drm/amd/display: change kzalloc to kcalloc indml1_validate()drivers/gpu/drm/amd/display/dc/resource/dcn30/dcn30_resource.c | 3 ++- drivers/gpu/drm/amd/display/dc/resource/dcn31/dcn31_resource.c | 3 ++- drivers/gpu/drm/amd/display/dc/resource/dcn314/dcn314_resource.c | 3 ++- drivers/gpu/drm/amd/display/dc/resource/dcn32/dcn32_resource.c | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-)---
base-commit:be5c7bbb3a64baf884481a1ba0c2f8fb2f93f7c3
change-id: 20250227-amd-display-a8342c55a9a0Best regards,