Commit 39dbbd4e authored by Shen Lichuan's avatar Shen Lichuan Committed by Krzysztof Kozlowski
Browse files

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: default avatarShen Lichuan <shenlichuan@vivo.com>
Link: https://lore.kernel.org/r/20240823114441.50648-1-shenlichuan@vivo.com


Signed-off-by: default avatarKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
parent e61f1a72
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -122,7 +122,7 @@ 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),
	dup_configs = kmemdup_array(configs, num_configs, sizeof(*dup_configs),
				    GFP_KERNEL);
	if (!dup_configs)
		return -ENOMEM;