Skip to contentSkip to conversation

ARM: omap2: Switch to use kmemdup_array()

PATCH Applied Andy Shevchenko 3 participants 5 messages Jun 6, 2024 – Jul 9, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM: omap2: Switch to use kmemdup_array()

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

---
 arch/arm/mach-omap2/omap_device.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-omap2/omap_device.c +1 -1
index fca7869c8075..800980057373 100644
@@ -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;
 
Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
maintainer
#1 lore raw

Hi,

Quoted 1 line · Andy Shevchenko

Let the kememdup_array() take care about multiplication and possible

          ^^^^^
          Typo.
Quoted 12 lines

overflows.

---
 arch/arm/mach-omap2/omap_device.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-omap2/omap_device.c +0 -0
index fca7869c8075..800980057373 100644

arch/arm/mach-omap2/omap_device.c static struct omap_device *omap_device_alloc(struct platform_device *pdev, · line 318

Quoted 5 lines
arch/arm/mach-omap2/omap_device.c +1 -1
@@ -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.

#2 lore raw
Quoted 5 lines · Aaro Koskinen
Quoted 1 line · Andy Shevchenko

Let the kememdup_array() take care about multiplication and possible

          ^^^^^
          Typo.

Aha, thanks!

Quoted 1 line
Quoted 1 line

overflows.

...

Quoted 4 lines

arch/arm/mach-omap2/omap_device.c static struct omap_device *omap_device_alloc(struct platform_device *pdev, · line 318

Quoted 2 lines
arch/arm/mach-omap2/omap_device.c +1 -1
-	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

Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer Reviewed-by
#3 lore raw
Quoted 13 lines · Andy Shevchenko
Quoted 5 lines · Aaro Koskinen
Quoted 1 line · Andy Shevchenko

Let the kememdup_array() take care about multiplication and possible

          ^^^^^
          Typo.

Aha, thanks!

Quoted 1 line
Quoted 1 line

overflows.

...

Quoted 7 lines
Quoted 4 lines

arch/arm/mach-omap2/omap_device.c static struct omap_device *omap_device_alloc(struct platform_device *pdev, · line 318

Quoted 2 lines
arch/arm/mach-omap2/omap_device.c +1 -1
-	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:

A.

maintainer Applied
#4 lore raw
In reply to Andy Shevchenko
Quoted 4 lines · Andy Shevchenko

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,

Signature · 1 line
Kevin Hilman <[email protected]>