media: atomisp: replace kmalloc() with kmalloc_array() in sh_css.c
Subsystems (4)
PATCH RESEND 1/1 media: atomisp: replace kmalloc() with kmalloc_array() in sh_css.c
Replace arithmetic in the kmalloc() function with the kmalloc_array() function, as this calculation method is unsafe.
Signed-off-by Andrei Khomenkov <[email protected]>
--- drivers/staging/media/atomisp/pci/sh_css.c | 41 +++++++++------------- 1 file changed, 16 insertions(+), 25 deletions(-)
drivers/staging/media/atomisp/pci/sh_css.c +16 -25
@@ -5819,36 +5819,31 @@ 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_array (descr->num_stage,sizeof (struct ia_css_frame_info ), +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_array (descr->num_stage,sizeof (struct ia_css_frame_info ), +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_array (descr->num_stage,sizeof (struct ia_css_frame_info ), +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_array (descr->num_stage,sizeof (struct ia_css_frame_info ), +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_array (descr->num_stage,sizeof (bool ),GFP_KERNEL );if (!descr->is_output_stage) { err = -ENOMEM ; goto ERR;
@@ -5974,29 +5969,25 @@ ia_css_pipe_create_cas_scaler_desc(struct ia_css_pipe *pipe, 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_array (descr->num_stage,sizeof (struct ia_css_frame_info ), +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_array (descr->num_stage,sizeof (struct ia_css_frame_info ), +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_array (descr->num_stage,sizeof (struct ia_css_frame_info ), +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_array (descr->num_stage,sizeof (bool ),GFP_KERNEL );if (!descr->is_output_stage) { err = -ENOMEM ; goto ERR;
Quoted 2 lines · Andrei Khomenkov
Replace arithmetic in the
kmalloc()function with thekmalloc_array()function, as this calculation method is unsafe.
...
drivers/staging/media/atomisp/pci/sh_css.c static int ia_css_pipe_create_cas_scaler_desc_single_output( · line 5822
Quoted 4 lines
drivers/staging/media/atomisp/pci/sh_css.c +1
-3- descr->in_info =kmalloc (descr->num_stage * -sizeof (struct ia_css_frame_info ), -GFP_KERNEL ); + descr->in_info = kmalloc_array(descr->num_stage, sizeof(struct ia_css_frame_info),
Why not sizeof(*descr->in_info) ?
...
Same Q to the rest.
Signature · 2 lines
With Best Regards, Andy Shevchenko