Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

clk: visconti: Switch to use kmemdup_array()

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

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20240814125513.2637955-3-andriy.shevchenko@linux.intel.com
Signed-off-by: Stephen Boyd <sboyd@kernel.org>

authored by

Andy Shevchenko and committed by
Stephen Boyd
1b2ed9df 0da7faca

+3 -3
+3 -3
drivers/clk/visconti/pll.c
··· 262 262 for (len = 0; rate_table[len].rate != 0; ) 263 263 len++; 264 264 pll->rate_count = len; 265 - pll->rate_table = kmemdup(rate_table, 266 - pll->rate_count * sizeof(struct visconti_pll_rate_table), 267 - GFP_KERNEL); 265 + pll->rate_table = kmemdup_array(rate_table, 266 + pll->rate_count, sizeof(*pll->rate_table), 267 + GFP_KERNEL); 268 268 WARN(!pll->rate_table, "%s: could not allocate rate table for %s\n", __func__, name); 269 269 270 270 init.ops = &visconti_pll_ops;