Skip to content

Commit 5e633f5

Browse files
Shen Lichuangeertu
authored andcommitted
pinctrl: renesas: Switch to use kmemdup_array()
Let kmemdup_array() take care of multiplication and possible overflow. Signed-off-by: Shen Lichuan <[email protected]> Reviewed-by: Geert Uytterhoeven <[email protected]> Link: https://lore.kernel.org/[email protected] Signed-off-by: Geert Uytterhoeven <[email protected]>
1 parent f73f63b commit 5e633f5

File tree

3 files changed

+3
-6
lines changed

3 files changed

+3
-6
lines changed

drivers/pinctrl/renesas/pinctrl-rzg2l.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -528,8 +528,7 @@ static int rzg2l_map_add_config(struct pinctrl_map *map,
528528
{
529529
unsigned long *cfgs;
530530

531-
cfgs = kmemdup(configs, num_configs * sizeof(*cfgs),
532-
GFP_KERNEL);
531+
cfgs = kmemdup_array(configs, num_configs, sizeof(*cfgs), GFP_KERNEL);
533532
if (!cfgs)
534533
return -ENOMEM;
535534

drivers/pinctrl/renesas/pinctrl-rzv2m.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,7 @@ static int rzv2m_map_add_config(struct pinctrl_map *map,
196196
{
197197
unsigned long *cfgs;
198198

199-
cfgs = kmemdup(configs, num_configs * sizeof(*cfgs),
200-
GFP_KERNEL);
199+
cfgs = kmemdup_array(configs, num_configs, sizeof(*cfgs), GFP_KERNEL);
201200
if (!cfgs)
202201
return -ENOMEM;
203202

drivers/pinctrl/renesas/pinctrl.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,7 @@ static int sh_pfc_map_add_config(struct pinctrl_map *map,
8383
{
8484
unsigned long *cfgs;
8585

86-
cfgs = kmemdup(configs, num_configs * sizeof(*cfgs),
87-
GFP_KERNEL);
86+
cfgs = kmemdup_array(configs, num_configs, sizeof(*cfgs), GFP_KERNEL);
8887
if (cfgs == NULL)
8988
return -ENOMEM;
9089

0 commit comments

Comments
 (0)