Skip to content

Commit 7666718

Browse files
andy-shevkrzk
authored andcommitted
clk: samsung: Switch to use kmemdup_array()
Let the kememdup_array() take care about multiplication and possible overflows. Signed-off-by: Andy Shevchenko <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Krzysztof Kozlowski <[email protected]>
1 parent b363a45 commit 7666718

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

drivers/clk/samsung/clk-cpu.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -689,8 +689,8 @@ static int __init exynos_register_cpu_clock(struct samsung_clk_provider *ctx,
689689
for (num_cfgs = 0; clk_data->cfg[num_cfgs].prate != 0; )
690690
num_cfgs++;
691691

692-
cpuclk->cfg = kmemdup(clk_data->cfg, sizeof(*clk_data->cfg) * num_cfgs,
693-
GFP_KERNEL);
692+
cpuclk->cfg = kmemdup_array(clk_data->cfg, num_cfgs, sizeof(*cpuclk->cfg),
693+
GFP_KERNEL);
694694
if (!cpuclk->cfg) {
695695
ret = -ENOMEM;
696696
goto unregister_clk_nb;

drivers/clk/samsung/clk-pll.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,10 +1286,10 @@ static void __init _samsung_clk_register_pll(struct samsung_clk_provider *ctx,
12861286
len++;
12871287

12881288
pll->rate_count = len;
1289-
pll->rate_table = kmemdup(pll_clk->rate_table,
1290-
pll->rate_count *
1291-
sizeof(struct samsung_pll_rate_table),
1292-
GFP_KERNEL);
1289+
pll->rate_table = kmemdup_array(pll_clk->rate_table,
1290+
pll->rate_count,
1291+
sizeof(*pll->rate_table),
1292+
GFP_KERNEL);
12931293
WARN(!pll->rate_table,
12941294
"%s: could not allocate rate table for %s\n",
12951295
__func__, pll_clk->name);

0 commit comments

Comments
 (0)