]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
pinctrl: samsung: Use kmemdup_array instead of kmemdup for multiple allocation
authorShen Lichuan <shenlichuan@vivo.com>
Fri, 23 Aug 2024 11:44:41 +0000 (19:44 +0800)
committerKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Fri, 23 Aug 2024 13:40:55 +0000 (15:40 +0200)
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 <shenlichuan@vivo.com>
Link: https://lore.kernel.org/r/20240823114441.50648-1-shenlichuan@vivo.com
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
drivers/pinctrl/samsung/pinctrl-samsung.c

index e4464ee815f935178ad65dcf59295142e1da38ec..675efa5d86a9af3b2b33ce68040dbaa87bd65d54 100644 (file)
@@ -122,8 +122,8 @@ static int add_map_configs(struct device *dev, struct pinctrl_map **map,
        if (WARN_ON(*num_maps == *reserved_maps))
                return -ENOSPC;
 
-       dup_configs = kmemdup(configs, num_configs * sizeof(*dup_configs),
-                             GFP_KERNEL);
+       dup_configs = kmemdup_array(configs, num_configs, sizeof(*dup_configs),
+                                   GFP_KERNEL);
        if (!dup_configs)
                return -ENOMEM;