[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240822061438.14617-1-shenlichuan@vivo.com>
Date: Thu, 22 Aug 2024 14:14:38 +0800
From: Shen Lichuan <shenlichuan@...o.com>
To: geert+renesas@...der.be,
linus.walleij@...aro.org
Cc: linux-renesas-soc@...r.kernel.org,
linux-gpio@...r.kernel.org,
linux-kernel@...r.kernel.org,
opensource.kernel@...o.com,
Shen Lichuan <shenlichuan@...o.com>
Subject: [PATCH v1] drivers/pinctrl/renesas: Switch to use kmemdup_array()
Let the kememdup_array() take care about
multiplication and possible overflows.
Signed-off-by: Shen Lichuan <shenlichuan@...o.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
Powered by blists - more mailing lists