diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2024-06-06 19:46:24 +0300 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2024-06-07 14:28:22 +0100 |
commit | f755d6955338bc704168629f70b380658a4918df (patch) | |
tree | f8a75ff977844a36bbd6491852436291245f2e01 /drivers/base | |
parent | 354662dc66f264b26c3e094162e0fad8715d009f (diff) |
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>
Diffstat (limited to 'drivers/base')
-rw-r--r-- | drivers/base/regmap/regcache.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/base/regmap/regcache.c b/drivers/base/regmap/regcache.c index bd7462c54271..7ec1ec605335 100644 --- a/drivers/base/regmap/regcache.c +++ b/drivers/base/regmap/regcache.c @@ -170,8 +170,8 @@ int regcache_init(struct regmap *map, const struct regmap_config *config) * a copy of it. */ if (config->reg_defaults) { - tmp_buf = kmemdup(config->reg_defaults, map->num_reg_defaults * - sizeof(struct reg_default), GFP_KERNEL); + tmp_buf = kmemdup_array(config->reg_defaults, map->num_reg_defaults, + sizeof(*map->reg_defaults), GFP_KERNEL); if (!tmp_buf) return -ENOMEM; map->reg_defaults = tmp_buf; |