Re: [PATCH v2] staging: media: atomisp: prefer kcalloc over kzalloc with multiply

From: Andy Shevchenko

Date: Sun Jun 07 2026 - 14:53:00 EST


On Sun, Jun 7, 2026 at 3:19 PM Andrew Soto <linux@xxxxxxxxxxxxxxx> wrote:
>
> Optimize memory allocation layout in sh_css_params.c by replacing
> the raw multiplication inside kzalloc() with a type-safe kcalloc()
> array allocation wrapper.
>
> This prevents potential integer overflow vulnerabilities by validating
> the array size calculations before interacting
> with the kernel heap allocator, aligning the driver with modern kernel
> memory allocation standards.

See my reply to v1.

...

> - write_buf = kzalloc(sizeof(u8) * 8192, GFP_KERNEL);
> + write_buf = kcalloc(8192, sizeof(u8), GFP_KERNEL);

While at it, you can switch to a more robust sizeof(*write_buf).

--
With Best Regards,
Andy Shevchenko