From: Dan Carpenter <error27@gmail.com>
To: Andrew Soto <linux@notrealandy.dev>
Cc: hansg@kernel.org, mchehab@kernel.org, gregkh@linuxfoundation.org,
andy@kernel.org, sakari.ailus@linux.intel.com,
linux-media@vger.kernel.org, linux-staging@lists.linux.dev,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] staging: media: atomisp: prefer kcalloc over kzalloc with multiply
Date: Mon, 8 Jun 2026 10:08:57 +0300 [thread overview]
Message-ID: <aiZqiXR5Z3Mt-CFk@stanley.mountain> (raw)
In-Reply-To: <20260606234427.9902-1-linux@notrealandy.dev>
On Sat, Jun 06, 2026 at 11:44:27PM +0000, Andrew Soto wrote:
> Optimize memory allocation layout
This part of the commit message is techno-bable. It's just
words that don't mean anything. I suppose teally they do
mean something, but it's not what the patch does...
> 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.
>
There is no risk of integer overflow when we multiply by 1.
> Signed-off-by: Andrew Soto <linux@notrealandy.dev>
> ---
> drivers/staging/media/atomisp/pci/sh_css_params.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/staging/media/atomisp/pci/sh_css_params.c b/drivers/staging/media/atomisp/pci/sh_css_params.c
> index fcebace11..9147ca047 100644
> --- a/drivers/staging/media/atomisp/pci/sh_css_params.c
> +++ b/drivers/staging/media/atomisp/pci/sh_css_params.c
> @@ -3716,7 +3716,7 @@ ia_css_ptr sh_css_store_sp_group_to_ddr(void)
>
> IA_CSS_ENTER_LEAVE_PRIVATE("void");
>
> - write_buf = kzalloc(sizeof(u8) * 8192, GFP_KERNEL);
> + write_buf = kcalloc(8192, sizeof(u8), GFP_KERNEL);
This should just be:
write_buf = kzalloc(8192, GFP_KERNEL);
If we weren't allocating a text buffer then the new way to write this
would be using kzalloc_objs().
regards,
dan carpenter
prev parent reply other threads:[~2026-06-08 7:09 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-06 23:44 [PATCH] staging: media: atomisp: prefer kcalloc over kzalloc with multiply Andrew Soto
2026-06-07 7:42 ` Andy Shevchenko
2026-06-07 12:18 ` [PATCH v2] " Andrew Soto
2026-06-07 18:52 ` Andy Shevchenko
2026-06-08 7:08 ` Dan Carpenter [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aiZqiXR5Z3Mt-CFk@stanley.mountain \
--to=error27@gmail.com \
--cc=andy@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=hansg@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=linux@notrealandy.dev \
--cc=mchehab@kernel.org \
--cc=sakari.ailus@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox