]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
media: atomisp: use kmalloc_objs for array allocations
authorPedro Pontes <pontescpedro@gmail.com>
Thu, 16 Apr 2026 13:42:15 +0000 (10:42 -0300)
committerSakari Ailus <sakari.ailus@linux.intel.com>
Wed, 20 May 2026 10:21:42 +0000 (13:21 +0300)
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>
drivers/staging/media/atomisp/pci/sh_css.c

index c136c1745eb93aaaffe5e4b9c5ee2607234d43ff..00082276f1db4c38441d191697b622857eafa4fd 100644 (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;