linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 1/1] ARM: omap2: Switch to use kmemdup_array()
@ 2024-06-06 16:51 Andy Shevchenko
  2024-06-06 19:32 ` Aaro Koskinen
  2024-07-09  0:13 ` Kevin Hilman
  0 siblings, 2 replies; 5+ messages in thread
From: Andy Shevchenko @ 2024-06-06 16:51 UTC (permalink / raw)
  To: Andy Shevchenko, linux-arm-kernel, linux-omap, linux-kernel
  Cc: Tony Lindgren, Russell King

Let the kememdup_array() take care about multiplication and possible
overflows.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 arch/arm/mach-omap2/omap_device.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c
index fca7869c8075..800980057373 100644
--- a/arch/arm/mach-omap2/omap_device.c
+++ b/arch/arm/mach-omap2/omap_device.c
@@ -315,7 +315,7 @@ static struct omap_device *omap_device_alloc(struct platform_device *pdev,
 
 	od->hwmods_cnt = oh_cnt;
 
-	hwmods = kmemdup(ohs, sizeof(struct omap_hwmod *) * oh_cnt, GFP_KERNEL);
+	hwmods = kmemdup_array(ohs, oh_cnt, sizeof(*hwmods), GFP_KERNEL);
 	if (!hwmods)
 		goto oda_exit2;
 
-- 
2.43.0.rc1.1336.g36b5255a03ac


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v1 1/1] ARM: omap2: Switch to use kmemdup_array()
  2024-06-06 16:51 [PATCH v1 1/1] ARM: omap2: Switch to use kmemdup_array() Andy Shevchenko
@ 2024-06-06 19:32 ` Aaro Koskinen
  2024-06-06 19:43   ` Andy Shevchenko
  2024-07-09  0:13 ` Kevin Hilman
  1 sibling, 1 reply; 5+ messages in thread
From: Aaro Koskinen @ 2024-06-06 19:32 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: linux-arm-kernel, linux-omap, linux-kernel, Tony Lindgren,
	Russell King

Hi,

On Thu, Jun 06, 2024 at 07:51:04PM +0300, Andy Shevchenko wrote:
> Let the kememdup_array() take care about multiplication and possible

          ^^^^^
          Typo.

> overflows.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  arch/arm/mach-omap2/omap_device.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c
> index fca7869c8075..800980057373 100644
> --- a/arch/arm/mach-omap2/omap_device.c
> +++ b/arch/arm/mach-omap2/omap_device.c
> @@ -315,7 +315,7 @@ static struct omap_device *omap_device_alloc(struct platform_device *pdev,
>  
>  	od->hwmods_cnt = oh_cnt;
>  
> -	hwmods = kmemdup(ohs, sizeof(struct omap_hwmod *) * oh_cnt, GFP_KERNEL);
> +	hwmods = kmemdup_array(ohs, oh_cnt, sizeof(*hwmods), GFP_KERNEL);

Maybe same result, but I guess the 3rd parameter should be count?

A.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v1 1/1] ARM: omap2: Switch to use kmemdup_array()
  2024-06-06 19:32 ` Aaro Koskinen
@ 2024-06-06 19:43   ` Andy Shevchenko
  2024-06-06 19:47     ` Aaro Koskinen
  0 siblings, 1 reply; 5+ messages in thread
From: Andy Shevchenko @ 2024-06-06 19:43 UTC (permalink / raw)
  To: Aaro Koskinen
  Cc: linux-arm-kernel, linux-omap, linux-kernel, Tony Lindgren,
	Russell King

On Thu, Jun 06, 2024 at 10:32:02PM +0300, Aaro Koskinen wrote:
> On Thu, Jun 06, 2024 at 07:51:04PM +0300, Andy Shevchenko wrote:
> > Let the kememdup_array() take care about multiplication and possible
> 
>           ^^^^^
>           Typo.

Aha, thanks!

> > overflows.

...

> > -	hwmods = kmemdup(ohs, sizeof(struct omap_hwmod *) * oh_cnt, GFP_KERNEL);
> > +	hwmods = kmemdup_array(ohs, oh_cnt, sizeof(*hwmods), GFP_KERNEL);
> 
> Maybe same result, but I guess the 3rd parameter should be count?

Actually it is going to be changed to follow kcalloc().
https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git/commit/?id=0ee14725471c

-- 
With Best Regards,
Andy Shevchenko



_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v1 1/1] ARM: omap2: Switch to use kmemdup_array()
  2024-06-06 19:43   ` Andy Shevchenko
@ 2024-06-06 19:47     ` Aaro Koskinen
  0 siblings, 0 replies; 5+ messages in thread
From: Aaro Koskinen @ 2024-06-06 19:47 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: linux-arm-kernel, linux-omap, linux-kernel, Tony Lindgren,
	Russell King

On Thu, Jun 06, 2024 at 10:43:07PM +0300, Andy Shevchenko wrote:
> On Thu, Jun 06, 2024 at 10:32:02PM +0300, Aaro Koskinen wrote:
> > On Thu, Jun 06, 2024 at 07:51:04PM +0300, Andy Shevchenko wrote:
> > > Let the kememdup_array() take care about multiplication and possible
> > 
> >           ^^^^^
> >           Typo.
> 
> Aha, thanks!
> 
> > > overflows.
> 
> ...
> 
> > > -	hwmods = kmemdup(ohs, sizeof(struct omap_hwmod *) * oh_cnt, GFP_KERNEL);
> > > +	hwmods = kmemdup_array(ohs, oh_cnt, sizeof(*hwmods), GFP_KERNEL);
> > 
> > Maybe same result, but I guess the 3rd parameter should be count?
> 
> Actually it is going to be changed to follow kcalloc().
> https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git/commit/?id=0ee14725471c

OK, good, you can add:

Reviewed-by: Aaro Koskinen <aaro.koskinen@iki.fi>

A.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v1 1/1] ARM: omap2: Switch to use kmemdup_array()
  2024-06-06 16:51 [PATCH v1 1/1] ARM: omap2: Switch to use kmemdup_array() Andy Shevchenko
  2024-06-06 19:32 ` Aaro Koskinen
@ 2024-07-09  0:13 ` Kevin Hilman
  1 sibling, 0 replies; 5+ messages in thread
From: Kevin Hilman @ 2024-07-09  0:13 UTC (permalink / raw)
  To: linux-arm-kernel, linux-omap, linux-kernel, Andy Shevchenko
  Cc: Tony Lindgren, Russell King


On Thu, 06 Jun 2024 19:51:04 +0300, Andy Shevchenko wrote:
> Let the kememdup_array() take care about multiplication and possible
> overflows.
> 
> 

Applied, thanks!

[1/1] ARM: omap2: Switch to use kmemdup_array()
      commit: ea77ad3d2dccaf223c556886b067c5e2657b40aa

Best regards,
-- 
Kevin Hilman <khilman@baylibre.com>



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

end of thread, other threads:[~2024-07-09  0:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-06 16:51 [PATCH v1 1/1] ARM: omap2: Switch to use kmemdup_array() Andy Shevchenko
2024-06-06 19:32 ` Aaro Koskinen
2024-06-06 19:43   ` Andy Shevchenko
2024-06-06 19:47     ` Aaro Koskinen
2024-07-09  0:13 ` Kevin Hilman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).