clk: mmp: 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-2-andriy.shevchenko@linux.intel.com Signed-off-by: Stephen Boyd <sboyd@kernel.org>
This commit is contained in:
parent
de7aeb5ddd
commit
0da7faca53
@ -447,7 +447,6 @@ struct clk *mmp_clk_register_mix(struct device *dev,
|
|||||||
struct mmp_clk_mix *mix;
|
struct mmp_clk_mix *mix;
|
||||||
struct clk *clk;
|
struct clk *clk;
|
||||||
struct clk_init_data init;
|
struct clk_init_data init;
|
||||||
size_t table_bytes;
|
|
||||||
|
|
||||||
mix = kzalloc(sizeof(*mix), GFP_KERNEL);
|
mix = kzalloc(sizeof(*mix), GFP_KERNEL);
|
||||||
if (!mix)
|
if (!mix)
|
||||||
@ -461,8 +460,8 @@ struct clk *mmp_clk_register_mix(struct device *dev,
|
|||||||
|
|
||||||
memcpy(&mix->reg_info, &config->reg_info, sizeof(config->reg_info));
|
memcpy(&mix->reg_info, &config->reg_info, sizeof(config->reg_info));
|
||||||
if (config->table) {
|
if (config->table) {
|
||||||
table_bytes = sizeof(*config->table) * config->table_size;
|
mix->table = kmemdup_array(config->table, config->table_size,
|
||||||
mix->table = kmemdup(config->table, table_bytes, GFP_KERNEL);
|
sizeof(*mix->table), GFP_KERNEL);
|
||||||
if (!mix->table)
|
if (!mix->table)
|
||||||
goto free_mix;
|
goto free_mix;
|
||||||
|
|
||||||
@ -470,9 +469,8 @@ struct clk *mmp_clk_register_mix(struct device *dev,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (config->mux_table) {
|
if (config->mux_table) {
|
||||||
table_bytes = sizeof(u32) * num_parents;
|
mix->mux_table = kmemdup_array(config->mux_table, num_parents,
|
||||||
mix->mux_table = kmemdup(config->mux_table, table_bytes,
|
sizeof(*mix->mux_table), GFP_KERNEL);
|
||||||
GFP_KERNEL);
|
|
||||||
if (!mix->mux_table) {
|
if (!mix->mux_table) {
|
||||||
kfree(mix->table);
|
kfree(mix->table);
|
||||||
goto free_mix;
|
goto free_mix;
|
||||||
|
Loading…
Reference in New Issue
Block a user