mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v1] drivers/pinctrl/renesas: Switch to use kmemdup_array()
@ 2024-08-22  6:14 Shen Lichuan
  2024-08-23 12:42 ` Geert Uytterhoeven
  2024-08-23 15:22 ` Andy Shevchenko
  0 siblings, 2 replies; 4+ messages in thread
From: Shen Lichuan @ 2024-08-22  6:14 UTC (permalink / raw)
  To: geert+renesas, linus.walleij
  Cc: linux-renesas-soc, linux-gpio, linux-kernel, opensource.kernel,
	Shen Lichuan

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

Signed-off-by: Shen Lichuan <shenlichuan@vivo.com>
---
 drivers/pinctrl/renesas/pinctrl-rzg2l.c | 4 ++--
 drivers/pinctrl/renesas/pinctrl-rzv2m.c | 4 ++--
 drivers/pinctrl/renesas/pinctrl.c       | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/pinctrl/renesas/pinctrl-rzg2l.c b/drivers/pinctrl/renesas/pinctrl-rzg2l.c
index 5e3d735a8570..afee3427763e 100644
--- a/drivers/pinctrl/renesas/pinctrl-rzg2l.c
+++ b/drivers/pinctrl/renesas/pinctrl-rzg2l.c
@@ -528,8 +528,8 @@ static int rzg2l_map_add_config(struct pinctrl_map *map,
 {
 	unsigned long *cfgs;
 
-	cfgs = kmemdup(configs, num_configs * sizeof(*cfgs),
-		       GFP_KERNEL);
+	cfgs = kmemdup_array(configs, num_configs,
+				sizeof(*cfgs), GFP_KERNEL);
 	if (!cfgs)
 		return -ENOMEM;
 
diff --git a/drivers/pinctrl/renesas/pinctrl-rzv2m.c b/drivers/pinctrl/renesas/pinctrl-rzv2m.c
index 0cae5472ac67..d3e1f42f4a56 100644
--- a/drivers/pinctrl/renesas/pinctrl-rzv2m.c
+++ b/drivers/pinctrl/renesas/pinctrl-rzv2m.c
@@ -196,8 +196,8 @@ static int rzv2m_map_add_config(struct pinctrl_map *map,
 {
 	unsigned long *cfgs;
 
-	cfgs = kmemdup(configs, num_configs * sizeof(*cfgs),
-		       GFP_KERNEL);
+	cfgs = kmemdup_array(configs, num_configs,
+				sizeof(*cfgs), GFP_KERNEL);
 	if (!cfgs)
 		return -ENOMEM;
 
diff --git a/drivers/pinctrl/renesas/pinctrl.c b/drivers/pinctrl/renesas/pinctrl.c
index 03e9bdbc82b9..cfcef35f0e7f 100644
--- a/drivers/pinctrl/renesas/pinctrl.c
+++ b/drivers/pinctrl/renesas/pinctrl.c
@@ -83,8 +83,8 @@ static int sh_pfc_map_add_config(struct pinctrl_map *map,
 {
 	unsigned long *cfgs;
 
-	cfgs = kmemdup(configs, num_configs * sizeof(*cfgs),
-		       GFP_KERNEL);
+	cfgs = kmemdup_array(configs, num_configs,
+				sizeof(*cfgs), GFP_KERNEL);
 	if (cfgs == NULL)
 		return -ENOMEM;
 
-- 
2.17.1


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

* Re: [PATCH v1] drivers/pinctrl/renesas: Switch to use kmemdup_array()
  2024-08-22  6:14 [PATCH v1] drivers/pinctrl/renesas: Switch to use kmemdup_array() Shen Lichuan
@ 2024-08-23 12:42 ` Geert Uytterhoeven
  2024-08-23 15:22 ` Andy Shevchenko
  1 sibling, 0 replies; 4+ messages in thread
From: Geert Uytterhoeven @ 2024-08-23 12:42 UTC (permalink / raw)
  To: Shen Lichuan
  Cc: linus.walleij, linux-renesas-soc, linux-gpio, linux-kernel,
	opensource.kernel

Hi Shen,

Thanks for your patch!

"pinctrl: renesas: ..."

On Thu, Aug 22, 2024 at 8:15 AM Shen Lichuan <shenlichuan@vivo.com> wrote:
> Let the kememdup_array() take care about

kmemdup_array

> multiplication and possible overflows.
>
> Signed-off-by: Shen Lichuan <shenlichuan@vivo.com>

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
i.e. will queue in renesas-pinctrl for v6.12 with the above fixed.

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH v1] drivers/pinctrl/renesas: Switch to use kmemdup_array()
  2024-08-22  6:14 [PATCH v1] drivers/pinctrl/renesas: Switch to use kmemdup_array() Shen Lichuan
  2024-08-23 12:42 ` Geert Uytterhoeven
@ 2024-08-23 15:22 ` Andy Shevchenko
  2024-08-23 15:30   ` Geert Uytterhoeven
  1 sibling, 1 reply; 4+ messages in thread
From: Andy Shevchenko @ 2024-08-23 15:22 UTC (permalink / raw)
  To: Shen Lichuan
  Cc: geert+renesas, linus.walleij, linux-renesas-soc, linux-gpio,
	linux-kernel, opensource.kernel

On Thu, Aug 22, 2024 at 02:14:38PM +0800, Shen Lichuan wrote:
> Let the kememdup_array() take care about
> multiplication and possible overflows.

> +	cfgs = kmemdup_array(configs, num_configs,
> +				sizeof(*cfgs), GFP_KERNEL);

Geert, don't you want to fix the indentation issues?
Perhaps even combining these to a single line?

...

> +	cfgs = kmemdup_array(configs, num_configs,
> +				sizeof(*cfgs), GFP_KERNEL);
>  	if (!cfgs)
>  		return -ENOMEM;

Ditto.

...

> +	cfgs = kmemdup_array(configs, num_configs,
> +				sizeof(*cfgs), GFP_KERNEL);

Ditto.

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH v1] drivers/pinctrl/renesas: Switch to use kmemdup_array()
  2024-08-23 15:22 ` Andy Shevchenko
@ 2024-08-23 15:30   ` Geert Uytterhoeven
  0 siblings, 0 replies; 4+ messages in thread
From: Geert Uytterhoeven @ 2024-08-23 15:30 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Shen Lichuan, linus.walleij, linux-renesas-soc, linux-gpio,
	linux-kernel, opensource.kernel

Hi Andy,

On Fri, Aug 23, 2024 at 5:22 PM Andy Shevchenko
<andriy.shevchenko@intel.com> wrote:
> On Thu, Aug 22, 2024 at 02:14:38PM +0800, Shen Lichuan wrote:
> > Let the kememdup_array() take care about
> > multiplication and possible overflows.
>
> > +     cfgs = kmemdup_array(configs, num_configs,
> > +                             sizeof(*cfgs), GFP_KERNEL);
>
> Geert, don't you want to fix the indentation issues?
> Perhaps even combining these to a single line?

I have already done so while applying ;-)

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

end of thread, other threads:[~2024-08-23 15:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-22  6:14 [PATCH v1] drivers/pinctrl/renesas: Switch to use kmemdup_array() Shen Lichuan
2024-08-23 12:42 ` Geert Uytterhoeven
2024-08-23 15:22 ` Andy Shevchenko
2024-08-23 15:30   ` Geert Uytterhoeven

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

all inboxes | Powered by JetHome®