diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2024-11-21 14:34:39 +0200 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2024-12-02 00:31:16 +0000 |
commit | b95cacd8d708bce5839db2767d425e20ae548fd8 (patch) | |
tree | 6ac55a24b02cdda23f0b264a6de07b7c05ff6fb4 | |
parent | 37c95f022a7a34823c123eeccdfe415b88562867 (diff) |
regmap: cache: rbtree: use krealloc_array() to replace krealloc()
Use krealloc_array() to replace krealloc() with multiplication.
krealloc_array() has multiply overflow check, which will be safer.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://patch.msgid.link/20241121123439.4180167-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r-- | drivers/base/regmap/regcache-rbtree.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/drivers/base/regmap/regcache-rbtree.c b/drivers/base/regmap/regcache-rbtree.c index 188438186589..a9d17f316e55 100644 --- a/drivers/base/regmap/regcache-rbtree.c +++ b/drivers/base/regmap/regcache-rbtree.c @@ -275,18 +275,16 @@ static int regcache_rbtree_insert_to_block(struct regmap *map, pos = (reg - base_reg) / map->reg_stride; offset = (rbnode->base_reg - base_reg) / map->reg_stride; - blk = krealloc(rbnode->block, - blklen * map->cache_word_size, - map->alloc_flags); + blk = krealloc_array(rbnode->block, blklen, map->cache_word_size, map->alloc_flags); if (!blk) return -ENOMEM; rbnode->block = blk; if (BITS_TO_LONGS(blklen) > BITS_TO_LONGS(rbnode->blklen)) { - present = krealloc(rbnode->cache_present, - BITS_TO_LONGS(blklen) * sizeof(*present), - map->alloc_flags); + present = krealloc_array(rbnode->cache_present, + BITS_TO_LONGS(blklen), sizeof(*present), + map->alloc_flags); if (!present) return -ENOMEM; |