Skip to content

Commit a9c470d

Browse files
Yu Jiaolianglinusw
authored andcommitted
pinctrl: nomadik: Use kmemdup_array instead of kmemdup for multiple allocation
Let the kememdup_array() take care about multiplication and possible overflows. Signed-off-by: Yu Jiaoliang <[email protected]> Link: https://lore.kernel.org/[email protected] Signed-off-by: Linus Walleij <[email protected]>
1 parent cd77b0d commit a9c470d

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

drivers/pinctrl/nomadik/pinctrl-abx500.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -716,8 +716,7 @@ static int abx500_dt_add_map_configs(struct pinctrl_map **map,
716716
if (*num_maps == *reserved_maps)
717717
return -ENOSPC;
718718

719-
dup_configs = kmemdup(configs, num_configs * sizeof(*dup_configs),
720-
GFP_KERNEL);
719+
dup_configs = kmemdup_array(configs, num_configs, sizeof(*dup_configs), GFP_KERNEL);
721720
if (!dup_configs)
722721
return -ENOMEM;
723722

drivers/pinctrl/nomadik/pinctrl-nomadik.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -601,8 +601,7 @@ static int nmk_dt_add_map_configs(struct pinctrl_map **map,
601601
if (*num_maps == *reserved_maps)
602602
return -ENOSPC;
603603

604-
dup_configs = kmemdup(configs, num_configs * sizeof(*dup_configs),
605-
GFP_KERNEL);
604+
dup_configs = kmemdup_array(configs, num_configs, sizeof(*dup_configs), GFP_KERNEL);
606605
if (!dup_configs)
607606
return -ENOMEM;
608607

0 commit comments

Comments
 (0)