Skip to content

Commit f755d69

Browse files
andy-shevbroonie
authored andcommitted
regmap: cache: Switch to use kmemdup_array()
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/20240606164717.3031107-4-andriy.shevchenko@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 354662d commit f755d69

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

drivers/base/regmap/regcache.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,8 @@ int regcache_init(struct regmap *map, const struct regmap_config *config)
170170
* a copy of it.
171171
*/
172172
if (config->reg_defaults) {
173-
tmp_buf = kmemdup(config->reg_defaults, map->num_reg_defaults *
174-
sizeof(struct reg_default), GFP_KERNEL);
173+
tmp_buf = kmemdup_array(config->reg_defaults, map->num_reg_defaults,
174+
sizeof(*map->reg_defaults), GFP_KERNEL);
175175
if (!tmp_buf)
176176
return -ENOMEM;
177177
map->reg_defaults = tmp_buf;

0 commit comments

Comments
 (0)