Skip to content

Commit 39dbbd4

Browse files
Shen Lichuankrzk
authored andcommitted
pinctrl: samsung: Use kmemdup_array instead of kmemdup for multiple allocation
Let the kmemdup_array() take care about multiplication and possible overflows. Using kmemdup_array() is more appropriate and makes the code easier to audit. Signed-off-by: Shen Lichuan <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Krzysztof Kozlowski <[email protected]>
1 parent e61f1a7 commit 39dbbd4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/pinctrl/samsung/pinctrl-samsung.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ static int add_map_configs(struct device *dev, struct pinctrl_map **map,
122122
if (WARN_ON(*num_maps == *reserved_maps))
123123
return -ENOSPC;
124124

125-
dup_configs = kmemdup(configs, num_configs * sizeof(*dup_configs),
126-
GFP_KERNEL);
125+
dup_configs = kmemdup_array(configs, num_configs, sizeof(*dup_configs),
126+
GFP_KERNEL);
127127
if (!dup_configs)
128128
return -ENOMEM;
129129

0 commit comments

Comments
 (0)