mirror of
https://github.com/torvalds/linux.git
synced 2026-07-28 01:55:51 +02:00
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:
parent
f4705de3a9
commit
11f94f5b1d
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user