Commit fc547ab0 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Heiko Stuebner
Browse files

clk: rockchip: 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-3-andriy.shevchenko@linux.intel.com


Signed-off-by: default avatarHeiko Stuebner <heiko@sntech.de>
parent 5c0e997e
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -369,8 +369,7 @@ struct clk *rockchip_clk_register_cpuclk(const char *name,

	if (nrates > 0) {
		cpuclk->rate_count = nrates;
		cpuclk->rate_table = kmemdup(rates,
					     sizeof(*rates) * nrates,
		cpuclk->rate_table = kmemdup_array(rates, nrates, sizeof(*rates),
						   GFP_KERNEL);
		if (!cpuclk->rate_table) {
			ret = -ENOMEM;
+4 −4
Original line number Diff line number Diff line
@@ -1136,9 +1136,9 @@ struct clk *rockchip_clk_register_pll(struct rockchip_clk_provider *ctx,
			len++;

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