* [PATCH v1 1/1] regmap: cache: rbtree: use krealloc_array() to replace krealloc()
@ 2024-11-21 12:34 Andy Shevchenko
2024-12-02 13:30 ` Mark Brown
0 siblings, 1 reply; 2+ messages in thread
From: Andy Shevchenko @ 2024-11-21 12:34 UTC (permalink / raw)
To: Andy Shevchenko, linux-kernel
Cc: Mark Brown, Greg Kroah-Hartman, Rafael J. Wysocki
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>
---
drivers/base/regmap/regcache-rbtree.c | 10 ++++------
1 file 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;
--
2.43.0.rc1.1336.g36b5255a03ac
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH v1 1/1] regmap: cache: rbtree: use krealloc_array() to replace krealloc()
2024-11-21 12:34 [PATCH v1 1/1] regmap: cache: rbtree: use krealloc_array() to replace krealloc() Andy Shevchenko
@ 2024-12-02 13:30 ` Mark Brown
0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2024-12-02 13:30 UTC (permalink / raw)
To: linux-kernel, Andy Shevchenko; +Cc: Greg Kroah-Hartman, Rafael J. Wysocki
On Thu, 21 Nov 2024 14:34:39 +0200, Andy Shevchenko wrote:
> Use krealloc_array() to replace krealloc() with multiplication.
> krealloc_array() has multiply overflow check, which will be safer.
>
>
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git for-next
Thanks!
[1/1] regmap: cache: rbtree: use krealloc_array() to replace krealloc()
commit: b95cacd8d708bce5839db2767d425e20ae548fd8
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-12-02 13:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-21 12:34 [PATCH v1 1/1] regmap: cache: rbtree: use krealloc_array() to replace krealloc() Andy Shevchenko
2024-12-02 13:30 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®