]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
clk: rockchip: Switch to use kmemdup_array()
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Thu, 6 Jun 2024 16:09:32 +0000 (19:09 +0300)
committerHeiko Stuebner <heiko@sntech.de>
Sun, 23 Jun 2024 20:10:48 +0000 (22:10 +0200)
Let the kememdup_array() take care about multiplication and possible
overflows.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20240606161028.2986587-3-andriy.shevchenko@linux.intel.com
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
drivers/clk/rockchip/clk-cpu.c
drivers/clk/rockchip/clk-pll.c

index 6ea7fba9f9e56f3c457113d242ce88b4bd8293de..398a226ad34ea2793d674c1ae29fdb2d3750e8ab 100644 (file)
@@ -369,9 +369,8 @@ struct clk *rockchip_clk_register_cpuclk(const char *name,
 
        if (nrates > 0) {
                cpuclk->rate_count = nrates;
-               cpuclk->rate_table = kmemdup(rates,
-                                            sizeof(*rates) * nrates,
-                                            GFP_KERNEL);
+               cpuclk->rate_table = kmemdup_array(rates, nrates, sizeof(*rates),
+                                                  GFP_KERNEL);
                if (!cpuclk->rate_table) {
                        ret = -ENOMEM;
                        goto unregister_notifier;
index 2d42eb6289267711c15f5e8275599e5c80995b76..606ce5458f54af92a2d84605e7c142925a96d557 100644 (file)
@@ -1136,10 +1136,10 @@ 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),
-                                       GFP_KERNEL);
+               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",
                        __func__, name);