On Thu Apr 16 10:42:15 2026 -0300, Pedro Pontes wrote:
> Convert manual kmalloc() multiplications to the modern kmalloc_objs()
> interface to improve type safety and prevent potential integer
> overflows.
> 
> Signed-off-by: Pedro Pontes <[email protected]>
> Signed-off-by: Sakari Ailus <[email protected]>

Patch committed.

Thanks,
Sakari Ailus

 drivers/staging/media/atomisp/pci/sh_css.c | 57 ++++++++++++++++--------------
 1 file changed, 30 insertions(+), 27 deletions(-)

---

diff --git a/drivers/staging/media/atomisp/pci/sh_css.c 
b/drivers/staging/media/atomisp/pci/sh_css.c
index c136c1745eb9..00082276f1db 100644
--- a/drivers/staging/media/atomisp/pci/sh_css.c
+++ b/drivers/staging/media/atomisp/pci/sh_css.c
@@ -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;
_______________________________________________
linuxtv-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to