* [PATCH v3] media: atomisp: replace kmalloc() with kmalloc_objs() in sh_css.c
@ 2026-06-15 19:45 Andrei Khomenkov
2026-06-16 7:44 ` Dan Carpenter
0 siblings, 1 reply; 2+ messages in thread
From: Andrei Khomenkov @ 2026-06-15 19:45 UTC (permalink / raw)
To: Greg Kroah-Hartman, Andy Shevchenko; +Cc: linux-staging, linux-media
Replace arithmetic in the kmalloc() function with the kmalloc_objs()
macro, as this calculation method is unsafe.
Suggested-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Andrei Khomenkov <khomenkov@mailbox.org>
---
v3:
- use 'kmalloc_objs()' macro instead of 'kmalloc_array()' function
- drop unused 'GFP_KERNEL' arguments since they are default
v2:
- use 'sizeof(*ptr)' instead of explicit type
v2: https://lore.kernel.org/linux-staging/20260613110712.71436-1-khomenkov@mailbox.org/
v1: https://lore.kernel.org/linux-staging/20260606095410.13968-1-khomenkov@mailbox.org/
drivers/staging/media/atomisp/pci/sh_css.c | 34 ++++++----------------
1 file changed, 9 insertions(+), 25 deletions(-)
diff --git a/drivers/staging/media/atomisp/pci/sh_css.c b/drivers/staging/media/atomisp/pci/sh_css.c
index 6cda5925fa45..0733d33101b2 100644
--- a/drivers/staging/media/atomisp/pci/sh_css.c
+++ b/drivers/staging/media/atomisp/pci/sh_css.c
@@ -5819,36 +5819,27 @@ 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);
+ kmalloc_objs(descr->in_info, descr->num_stage);
if (!descr->in_info) {
err = -ENOMEM;
goto ERR;
}
- descr->internal_out_info = kmalloc(descr->num_stage *
- sizeof(struct ia_css_frame_info),
- GFP_KERNEL);
+ kmalloc_objs(descr->internal_out_info, descr->num_stage);
if (!descr->internal_out_info) {
err = -ENOMEM;
goto ERR;
}
- descr->out_info = kmalloc(descr->num_stage *
- sizeof(struct ia_css_frame_info),
- GFP_KERNEL);
+ kmalloc_objs(descr->out_info, descr->num_stage);
if (!descr->out_info) {
err = -ENOMEM;
goto ERR;
}
- descr->vf_info = kmalloc(descr->num_stage *
- sizeof(struct ia_css_frame_info),
- GFP_KERNEL);
+ kmalloc_objs(descr->vf_info, descr->num_stage);
if (!descr->vf_info) {
err = -ENOMEM;
goto ERR;
}
- descr->is_output_stage = kmalloc(descr->num_stage * sizeof(bool),
- GFP_KERNEL);
+ kmalloc_objs(descr->is_output_stage, descr->num_stage);
if (!descr->is_output_stage) {
err = -ENOMEM;
goto ERR;
@@ -5974,29 +5965,22 @@ 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);
+ kmalloc_objs(descr->internal_out_info, descr->num_stage);
if (!descr->internal_out_info) {
err = -ENOMEM;
goto ERR;
}
- descr->out_info = kmalloc(descr->num_stage *
- sizeof(struct ia_css_frame_info),
- GFP_KERNEL);
+ kmalloc_objs(descr->out_info, descr->num_stage);
if (!descr->out_info) {
err = -ENOMEM;
goto ERR;
}
- descr->vf_info = kmalloc(descr->num_stage *
- sizeof(struct ia_css_frame_info),
- GFP_KERNEL);
+ kmalloc_objs(descr->vf_info, descr->num_stage);
if (!descr->vf_info) {
err = -ENOMEM;
goto ERR;
}
- descr->is_output_stage = kmalloc(descr->num_stage * sizeof(bool),
- GFP_KERNEL);
+ kmalloc_objs(descr->is_output_stage, descr->num_stage);
if (!descr->is_output_stage) {
err = -ENOMEM;
goto ERR;
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v3] media: atomisp: replace kmalloc() with kmalloc_objs() in sh_css.c
2026-06-15 19:45 [PATCH v3] media: atomisp: replace kmalloc() with kmalloc_objs() in sh_css.c Andrei Khomenkov
@ 2026-06-16 7:44 ` Dan Carpenter
0 siblings, 0 replies; 2+ messages in thread
From: Dan Carpenter @ 2026-06-16 7:44 UTC (permalink / raw)
To: Andrei Khomenkov
Cc: Greg Kroah-Hartman, Andy Shevchenko, linux-staging, linux-media
On Mon, Jun 15, 2026 at 10:45:48PM +0300, Andrei Khomenkov wrote:
> Replace arithmetic in the kmalloc() function with the kmalloc_objs()
> macro, as this calculation method is unsafe.
>
> Suggested-by: Andy Shevchenko <andriy.shevchenko@intel.com>
> Signed-off-by: Andrei Khomenkov <khomenkov@mailbox.org>
> ---
Are you working against the devel-next tree? This doesn't apply to
linux-next.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-06-16 7:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-15 19:45 [PATCH v3] media: atomisp: replace kmalloc() with kmalloc_objs() in sh_css.c Andrei Khomenkov
2026-06-16 7:44 ` Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox