Commit 76667188 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Krzysztof Kozlowski
Browse files

clk: samsung: Switch to use kmemdup_array()



Let the kememdup_array() take care about multiplication and possible
overflows.

Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20240606161028.2986587-4-andriy.shevchenko@linux.intel.com


Signed-off-by: default avatarKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
parent b363a459
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -689,7 +689,7 @@ static int __init exynos_register_cpu_clock(struct samsung_clk_provider *ctx,
	for (num_cfgs = 0; clk_data->cfg[num_cfgs].prate != 0; )
		num_cfgs++;

	cpuclk->cfg = kmemdup(clk_data->cfg, sizeof(*clk_data->cfg) * num_cfgs,
	cpuclk->cfg = kmemdup_array(clk_data->cfg, num_cfgs, sizeof(*cpuclk->cfg),
				    GFP_KERNEL);
	if (!cpuclk->cfg) {
		ret = -ENOMEM;
+4 −4
Original line number Diff line number Diff line
@@ -1286,9 +1286,9 @@ static void __init _samsung_clk_register_pll(struct samsung_clk_provider *ctx,
			len++;

		pll->rate_count = len;
		pll->rate_table = kmemdup(pll_clk->rate_table,
					pll->rate_count *
					sizeof(struct samsung_pll_rate_table),
		pll->rate_table = kmemdup_array(pll_clk->rate_table,
						pll->rate_count,
						sizeof(*pll->rate_table),
						GFP_KERNEL);
		WARN(!pll->rate_table,
			"%s: could not allocate rate table for %s\n",