public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/2] staging: media: atomisp: use kmalloc_array() for sh_css_blob_info
@ 2026-03-13 15:29 Lin YuChen
  2026-03-13 16:04 ` Andy Shevchenko
  0 siblings, 1 reply; 4+ messages in thread
From: Lin YuChen @ 2026-03-13 15:29 UTC (permalink / raw)
  To: andy, hansg, mchehab, gregkh
  Cc: sakari.ailus, linux-kernel, linux-media, linux-staging,
	starpt.official

Replace the open-coded multiplication in kmalloc() with kmalloc_array()
to provide overflow protection and improve code readability.

Signed-off-by: Lin YuChen <starpt.official@gmail.com>
---
v2:
 - Remove unnecessary parentheses in kmalloc_array() call as suggested
   by Andy Shevchenko.
 drivers/staging/media/atomisp/pci/sh_css_firmware.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/sh_css_firmware.c b/drivers/staging/media/atomisp/pci/sh_css_firmware.c
index 57ecf5549c23..af12df2f9b09 100644
--- a/drivers/staging/media/atomisp/pci/sh_css_firmware.c
+++ b/drivers/staging/media/atomisp/pci/sh_css_firmware.c
@@ -253,9 +253,9 @@ sh_css_load_firmware(struct device *dev, const char *fw_data,
 	sh_css_num_binaries = file_header->binary_nr;
 	/* Only allocate memory for ISP blob info */
 	if (sh_css_num_binaries > NUM_OF_SPS) {
-		sh_css_blob_info = kmalloc(
-		    (sh_css_num_binaries - NUM_OF_SPS) *
-		    sizeof(*sh_css_blob_info), GFP_KERNEL);
+		sh_css_blob_info =
+			kmalloc_array(sh_css_num_binaries - NUM_OF_SPS,
+				      sizeof(*sh_css_blob_info), GFP_KERNEL);
 		if (!sh_css_blob_info)
 			return -ENOMEM;
 	} else {
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] staging: media: atomisp: use kmalloc_array() for sh_css_blob_info
  2026-03-13 15:29 [PATCH 2/2] staging: media: atomisp: use kmalloc_array() for sh_css_blob_info Lin YuChen
@ 2026-03-13 16:04 ` Andy Shevchenko
  2026-03-13 17:46   ` YuChen Lin
  2026-03-13 17:55   ` [PATCH v3] " Lin YuChen
  0 siblings, 2 replies; 4+ messages in thread
From: Andy Shevchenko @ 2026-03-13 16:04 UTC (permalink / raw)
  To: Lin YuChen
  Cc: andy, hansg, mchehab, gregkh, sakari.ailus, linux-kernel,
	linux-media, linux-staging

On Fri, Mar 13, 2026 at 11:29:36PM +0800, Lin YuChen wrote:
> Replace the open-coded multiplication in kmalloc() with kmalloc_array()
> to provide overflow protection and improve code readability.

> ---
> v2:
>  - Remove unnecessary parentheses in kmalloc_array() call as suggested
>    by Andy Shevchenko.

This marked as v1 and 2/2, where is the patch 1, and what is v2 here?

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] staging: media: atomisp: use kmalloc_array() for sh_css_blob_info
  2026-03-13 16:04 ` Andy Shevchenko
@ 2026-03-13 17:46   ` YuChen Lin
  2026-03-13 17:55   ` [PATCH v3] " Lin YuChen
  1 sibling, 0 replies; 4+ messages in thread
From: YuChen Lin @ 2026-03-13 17:46 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: andy, hansg, mchehab, gregkh, sakari.ailus, linux-kernel,
	linux-media, linux-staging

On Sat, Mar 14, 2026 at 12:04 AM Andy Shevchenko
<andriy.shevchenko@intel.com> wrote:
>
> On Fri, Mar 13, 2026 at 11:29:36PM +0800, Lin YuChen wrote:
> > Replace the open-coded multiplication in kmalloc() with kmalloc_array()
> > to provide overflow protection and improve code readability.
>
> > ---
> > v2:
> >  - Remove unnecessary parentheses in kmalloc_array() call as suggested
> >    by Andy Shevchenko.
>
> This marked as v1 and 2/2, where is the patch 1, and what is v2 here?
>
> --
> With Best Regards,
> Andy Shevchenko
>
>

Hi Andy,

Sorry for the confusion. I made a mistake in the versioning and numbering
while using git format-patch. This was intended to be v2 of the single patch,
but I incorrectly sent it as v1 2/2.

I will send a clean v3 shortly with the correct headers and changelog
to clear this up.

Thanks, Lin YuChen

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v3] staging: media: atomisp: use kmalloc_array() for sh_css_blob_info
  2026-03-13 16:04 ` Andy Shevchenko
  2026-03-13 17:46   ` YuChen Lin
@ 2026-03-13 17:55   ` Lin YuChen
  1 sibling, 0 replies; 4+ messages in thread
From: Lin YuChen @ 2026-03-13 17:55 UTC (permalink / raw)
  To: andy, hansg, mchehab, gregkh
  Cc: sakari.ailus, linux-kernel, linux-media, linux-staging,
	starpt.official

Replace the open-coded multiplication in kmalloc() with kmalloc_array()
to provide overflow protection and improve code readability.

Signed-off-by: Lin YuChen <starpt.official@gmail.com>
---
v3:
 - Resend as a single patch to fix the incorrect versioning and
   numbering (1/2, 2/2) in the previous submission.
v2:
 - Remove unnecessary parentheses in kmalloc_array() call as suggested
   by Andy Shevchenko.
 drivers/staging/media/atomisp/pci/sh_css_firmware.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/sh_css_firmware.c b/drivers/staging/media/atomisp/pci/sh_css_firmware.c
index 57ecf5549c23..af12df2f9b09 100644
--- a/drivers/staging/media/atomisp/pci/sh_css_firmware.c
+++ b/drivers/staging/media/atomisp/pci/sh_css_firmware.c
@@ -253,9 +253,9 @@ sh_css_load_firmware(struct device *dev, const char *fw_data,
 	sh_css_num_binaries = file_header->binary_nr;
 	/* Only allocate memory for ISP blob info */
 	if (sh_css_num_binaries > NUM_OF_SPS) {
-		sh_css_blob_info = kmalloc(
-		    (sh_css_num_binaries - NUM_OF_SPS) *
-		    sizeof(*sh_css_blob_info), GFP_KERNEL);
+		sh_css_blob_info =
+			kmalloc_array(sh_css_num_binaries - NUM_OF_SPS,
+				      sizeof(*sh_css_blob_info), GFP_KERNEL);
 		if (!sh_css_blob_info)
 			return -ENOMEM;
 	} else {
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-03-13 17:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-13 15:29 [PATCH 2/2] staging: media: atomisp: use kmalloc_array() for sh_css_blob_info Lin YuChen
2026-03-13 16:04 ` Andy Shevchenko
2026-03-13 17:46   ` YuChen Lin
2026-03-13 17:55   ` [PATCH v3] " Lin YuChen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox