media: atomisp: use kmalloc_objs for array allocations

Convert manual kmalloc() multiplications to the modern kmalloc_objs()
interface to improve type safety and prevent potential integer
overflows.

Signed-off-by: Pedro Pontes <pontescpedro@gmail.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
This commit is contained in:
Pedro Pontes 2026-04-16 10:42:15 -03:00 committed by Sakari Ailus
parent f4705de3a9
commit 11f94f5b1d

View File

@ -5819,36 +5819,37 @@ static int ia_css_pipe_create_cas_scaler_desc_single_output(
i *= max_scale_factor_per_stage;
}
descr->in_info = kmalloc(descr->num_stage *
sizeof(struct ia_css_frame_info),
GFP_KERNEL);
descr->in_info = kmalloc_objs(*descr->in_info,
descr->num_stage,
GFP_KERNEL);
if (!descr->in_info) {
err = -ENOMEM;
goto ERR;
}
descr->internal_out_info = kmalloc(descr->num_stage *
sizeof(struct ia_css_frame_info),
GFP_KERNEL);
descr->internal_out_info = kmalloc_objs(*descr->internal_out_info,
descr->num_stage,
GFP_KERNEL);
if (!descr->internal_out_info) {
err = -ENOMEM;
goto ERR;
}
descr->out_info = kmalloc(descr->num_stage *
sizeof(struct ia_css_frame_info),
GFP_KERNEL);
descr->out_info = kmalloc_objs(*descr->out_info,
descr->num_stage,
GFP_KERNEL);
if (!descr->out_info) {
err = -ENOMEM;
goto ERR;
}
descr->vf_info = kmalloc(descr->num_stage *
sizeof(struct ia_css_frame_info),
GFP_KERNEL);
descr->vf_info = kmalloc_objs(*descr->vf_info,
descr->num_stage,
GFP_KERNEL);
if (!descr->vf_info) {
err = -ENOMEM;
goto ERR;
}
descr->is_output_stage = kmalloc(descr->num_stage * sizeof(bool),
GFP_KERNEL);
descr->is_output_stage = kmalloc_objs(*descr->is_output_stage,
descr->num_stage,
GFP_KERNEL);
if (!descr->is_output_stage) {
err = -ENOMEM;
goto ERR;
@ -5968,35 +5969,37 @@ ia_css_pipe_create_cas_scaler_desc(struct ia_css_pipe *pipe,
descr->num_stage = num_stages;
descr->in_info = kmalloc_objs(struct ia_css_frame_info,
descr->num_stage);
descr->in_info = kmalloc_objs(*descr->in_info,
descr->num_stage,
GFP_KERNEL);
if (!descr->in_info) {
err = -ENOMEM;
goto ERR;
}
descr->internal_out_info = kmalloc(descr->num_stage *
sizeof(struct ia_css_frame_info),
GFP_KERNEL);
descr->internal_out_info = kmalloc_objs(*descr->internal_out_info,
descr->num_stage,
GFP_KERNEL);
if (!descr->internal_out_info) {
err = -ENOMEM;
goto ERR;
}
descr->out_info = kmalloc(descr->num_stage *
sizeof(struct ia_css_frame_info),
GFP_KERNEL);
descr->out_info = kmalloc_objs(*descr->out_info,
descr->num_stage,
GFP_KERNEL);
if (!descr->out_info) {
err = -ENOMEM;
goto ERR;
}
descr->vf_info = kmalloc(descr->num_stage *
sizeof(struct ia_css_frame_info),
GFP_KERNEL);
descr->vf_info = kmalloc_objs(*descr->vf_info,
descr->num_stage,
GFP_KERNEL);
if (!descr->vf_info) {
err = -ENOMEM;
goto ERR;
}
descr->is_output_stage = kmalloc(descr->num_stage * sizeof(bool),
GFP_KERNEL);
descr->is_output_stage = kmalloc_objs(*descr->is_output_stage,
descr->num_stage,
GFP_KERNEL);
if (!descr->is_output_stage) {
err = -ENOMEM;
goto ERR;