Commit bce84306 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Mark Brown

regmap: maple: Switch to use kmemdup_array()

Let the kememdup_array() take care about multiplication and possible
overflows.
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20240606164717.3031107-5-andriy.shevchenko@linux.intel.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent f755d695
...@@ -132,9 +132,9 @@ static int regcache_maple_drop(struct regmap *map, unsigned int min, ...@@ -132,9 +132,9 @@ static int regcache_maple_drop(struct regmap *map, unsigned int min,
lower_index = mas.index; lower_index = mas.index;
lower_last = min -1; lower_last = min -1;
lower = kmemdup(entry, ((min - mas.index) * lower = kmemdup_array(entry,
sizeof(unsigned long)), min - mas.index, sizeof(*lower),
map->alloc_flags); map->alloc_flags);
if (!lower) { if (!lower) {
ret = -ENOMEM; ret = -ENOMEM;
goto out_unlocked; goto out_unlocked;
...@@ -145,10 +145,9 @@ static int regcache_maple_drop(struct regmap *map, unsigned int min, ...@@ -145,10 +145,9 @@ static int regcache_maple_drop(struct regmap *map, unsigned int min,
upper_index = max + 1; upper_index = max + 1;
upper_last = mas.last; upper_last = mas.last;
upper = kmemdup(&entry[max - mas.index + 1], upper = kmemdup_array(&entry[max - mas.index + 1],
((mas.last - max) * mas.last - max, sizeof(*upper),
sizeof(unsigned long)), map->alloc_flags);
map->alloc_flags);
if (!upper) { if (!upper) {
ret = -ENOMEM; ret = -ENOMEM;
goto out_unlocked; goto out_unlocked;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment