* [PATCH v1 0/4] regmap: Switch to use kmemdup_array()
@ 2024-06-06 16:46 Andy Shevchenko
2024-06-06 16:46 ` [PATCH v1 1/4] " Andy Shevchenko
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Andy Shevchenko @ 2024-06-06 16:46 UTC (permalink / raw)
To: Mark Brown, Andy Shevchenko, linux-kernel
Cc: Greg Kroah-Hartman, Rafael J. Wysocki
Replace open coded kmemdup_array(), which does an additional
overflow check.
While at it, fix one minor issue in regcache.c.
Andy Shevchenko (4):
regmap: Switch to use kmemdup_array()
regmap: cache: Use correct type of the rb_for_each() parameter
regmap: cache: Switch to use kmemdup_array()
regmap: maple: Switch to use kmemdup_array()
drivers/base/regmap/regcache-maple.c | 13 ++++++-------
drivers/base/regmap/regcache.c | 6 +++---
drivers/base/regmap/regmap.c | 2 +-
3 files changed, 10 insertions(+), 11 deletions(-)
--
2.43.0.rc1.1336.g36b5255a03ac
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v1 1/4] regmap: Switch to use kmemdup_array()
2024-06-06 16:46 [PATCH v1 0/4] regmap: Switch to use kmemdup_array() Andy Shevchenko
@ 2024-06-06 16:46 ` Andy Shevchenko
2024-06-06 16:46 ` [PATCH v1 2/4] regmap: cache: Use correct type of the rb_for_each() parameter Andy Shevchenko
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2024-06-06 16:46 UTC (permalink / raw)
To: Mark Brown, Andy Shevchenko, linux-kernel
Cc: Greg Kroah-Hartman, Rafael J. Wysocki
Let the kememdup_array() take care about multiplication and possible
overflows.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/base/regmap/regmap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index 0a34dd3c4f38..88c02b71b2ee 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -2347,7 +2347,7 @@ int regmap_bulk_write(struct regmap *map, unsigned int reg, const void *val,
} else {
void *wval;
- wval = kmemdup(val, val_count * val_bytes, map->alloc_flags);
+ wval = kmemdup_array(val, val_count, val_bytes, map->alloc_flags);
if (!wval)
return -ENOMEM;
--
2.43.0.rc1.1336.g36b5255a03ac
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v1 2/4] regmap: cache: Use correct type of the rb_for_each() parameter
2024-06-06 16:46 [PATCH v1 0/4] regmap: Switch to use kmemdup_array() Andy Shevchenko
2024-06-06 16:46 ` [PATCH v1 1/4] " Andy Shevchenko
@ 2024-06-06 16:46 ` Andy Shevchenko
2024-06-06 16:46 ` [PATCH v1 3/4] regmap: cache: Switch to use kmemdup_array() Andy Shevchenko
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2024-06-06 16:46 UTC (permalink / raw)
To: Mark Brown, Andy Shevchenko, linux-kernel
Cc: Greg Kroah-Hartman, Rafael J. Wysocki
Compiler is not happy:
regcache.c:410:9: warning: Using plain integer as NULL pointer
Replace integer 0 by NULL.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/base/regmap/regcache.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/base/regmap/regcache.c b/drivers/base/regmap/regcache.c
index 2e41cb12b8e2..bd7462c54271 100644
--- a/drivers/base/regmap/regcache.c
+++ b/drivers/base/regmap/regcache.c
@@ -407,7 +407,7 @@ int regcache_sync(struct regmap *map)
* have gone out of sync, force writes of all the paging
* registers.
*/
- rb_for_each(node, 0, &map->range_tree, rbtree_all) {
+ rb_for_each(node, NULL, &map->range_tree, rbtree_all) {
struct regmap_range_node *this =
rb_entry(node, struct regmap_range_node, node);
--
2.43.0.rc1.1336.g36b5255a03ac
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v1 3/4] regmap: cache: Switch to use kmemdup_array()
2024-06-06 16:46 [PATCH v1 0/4] regmap: Switch to use kmemdup_array() Andy Shevchenko
2024-06-06 16:46 ` [PATCH v1 1/4] " Andy Shevchenko
2024-06-06 16:46 ` [PATCH v1 2/4] regmap: cache: Use correct type of the rb_for_each() parameter Andy Shevchenko
@ 2024-06-06 16:46 ` Andy Shevchenko
2024-06-06 16:46 ` [PATCH v1 4/4] regmap: maple: " Andy Shevchenko
2024-06-07 21:58 ` [PATCH v1 0/4] regmap: " Mark Brown
4 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2024-06-06 16:46 UTC (permalink / raw)
To: Mark Brown, Andy Shevchenko, linux-kernel
Cc: Greg Kroah-Hartman, Rafael J. Wysocki
Let the kememdup_array() take care about multiplication and possible
overflows.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/base/regmap/regcache.c | 4 ++--
1 file 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;
--
2.43.0.rc1.1336.g36b5255a03ac
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v1 4/4] regmap: maple: Switch to use kmemdup_array()
2024-06-06 16:46 [PATCH v1 0/4] regmap: Switch to use kmemdup_array() Andy Shevchenko
` (2 preceding siblings ...)
2024-06-06 16:46 ` [PATCH v1 3/4] regmap: cache: Switch to use kmemdup_array() Andy Shevchenko
@ 2024-06-06 16:46 ` Andy Shevchenko
2024-06-07 21:58 ` [PATCH v1 0/4] regmap: " Mark Brown
4 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2024-06-06 16:46 UTC (permalink / raw)
To: Mark Brown, Andy Shevchenko, linux-kernel
Cc: Greg Kroah-Hartman, Rafael J. Wysocki
Let the kememdup_array() take care about multiplication and possible
overflows.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/base/regmap/regcache-maple.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/drivers/base/regmap/regcache-maple.c b/drivers/base/regmap/regcache-maple.c
index e42433404854..f0df2da6d522 100644
--- a/drivers/base/regmap/regcache-maple.c
+++ b/drivers/base/regmap/regcache-maple.c
@@ -132,9 +132,9 @@ static int regcache_maple_drop(struct regmap *map, unsigned int min,
lower_index = mas.index;
lower_last = min -1;
- lower = kmemdup(entry, ((min - mas.index) *
- sizeof(unsigned long)),
- map->alloc_flags);
+ lower = kmemdup_array(entry,
+ min - mas.index, sizeof(*lower),
+ map->alloc_flags);
if (!lower) {
ret = -ENOMEM;
goto out_unlocked;
@@ -145,10 +145,9 @@ static int regcache_maple_drop(struct regmap *map, unsigned int min,
upper_index = max + 1;
upper_last = mas.last;
- upper = kmemdup(&entry[max - mas.index + 1],
- ((mas.last - max) *
- sizeof(unsigned long)),
- map->alloc_flags);
+ upper = kmemdup_array(&entry[max - mas.index + 1],
+ mas.last - max, sizeof(*upper),
+ map->alloc_flags);
if (!upper) {
ret = -ENOMEM;
goto out_unlocked;
--
2.43.0.rc1.1336.g36b5255a03ac
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v1 0/4] regmap: Switch to use kmemdup_array()
2024-06-06 16:46 [PATCH v1 0/4] regmap: Switch to use kmemdup_array() Andy Shevchenko
` (3 preceding siblings ...)
2024-06-06 16:46 ` [PATCH v1 4/4] regmap: maple: " Andy Shevchenko
@ 2024-06-07 21:58 ` Mark Brown
4 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2024-06-07 21:58 UTC (permalink / raw)
To: linux-kernel, Andy Shevchenko; +Cc: Greg Kroah-Hartman, Rafael J. Wysocki
On Thu, 06 Jun 2024 19:46:21 +0300, Andy Shevchenko wrote:
> Replace open coded kmemdup_array(), which does an additional
> overflow check.
>
> While at it, fix one minor issue in regcache.c.
>
> Andy Shevchenko (4):
> regmap: Switch to use kmemdup_array()
> regmap: cache: Use correct type of the rb_for_each() parameter
> regmap: cache: Switch to use kmemdup_array()
> regmap: maple: Switch to use kmemdup_array()
>
> [...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git for-next
Thanks!
[1/4] regmap: Switch to use kmemdup_array()
commit: 540c53d158d947db1249614d47437c660ba0b959
[2/4] regmap: cache: Use correct type of the rb_for_each() parameter
commit: 354662dc66f264b26c3e094162e0fad8715d009f
[3/4] regmap: cache: Switch to use kmemdup_array()
commit: f755d6955338bc704168629f70b380658a4918df
[4/4] regmap: maple: Switch to use kmemdup_array()
commit: bce843065804f770ac469d32a3d455b9a997b55f
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] 6+ messages in thread
end of thread, other threads:[~2024-06-07 21:58 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-06 16:46 [PATCH v1 0/4] regmap: Switch to use kmemdup_array() Andy Shevchenko
2024-06-06 16:46 ` [PATCH v1 1/4] " Andy Shevchenko
2024-06-06 16:46 ` [PATCH v1 2/4] regmap: cache: Use correct type of the rb_for_each() parameter Andy Shevchenko
2024-06-06 16:46 ` [PATCH v1 3/4] regmap: cache: Switch to use kmemdup_array() Andy Shevchenko
2024-06-06 16:46 ` [PATCH v1 4/4] regmap: maple: " Andy Shevchenko
2024-06-07 21:58 ` [PATCH v1 0/4] regmap: " Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox