mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Mark Brown <broonie@kernel.org>,
	linux-kernel@vger.kernel.org, driver-core@lists.linux.dev
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Danilo Krummrich <dakr@kernel.org>,
	Johan Hovold <johan@kernel.org>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: [PATCH v1 1/4] regmap: Switch to use kmemdup_array()
Date: Tue, 10 Nov 2026 10:36:59 +0100	[thread overview]
Message-ID: <20261110093820.454682-2-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <20261110093820.454682-1-andriy.shevchenko@linux.intel.com>

Let the kmemdup_array() take care about multiplication and possible
overflows.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/base/regmap/regmap.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index bc4e53ce8ecc..e327850ecc97 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -2595,9 +2595,9 @@ static int _regmap_multi_reg_write(struct regmap *map,
 		 */
 		range = _regmap_range_lookup(map, reg);
 		if (range || regs[i].delay_us) {
-			size_t len = sizeof(struct reg_sequence)*num_regs;
-			struct reg_sequence *base = kmemdup(regs, len,
-							   GFP_KERNEL);
+			struct reg_sequence *base;
+
+			base = kmemdup_array(regs, num_regs, sizeof(*regs), GFP_KERNEL);
 			if (!base)
 				return -ENOMEM;
 			ret = _regmap_range_multi_paged_reg_write(map, base,
-- 
2.50.1


  reply	other threads:[~2026-11-10  9:38 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-10  9:36 [PATCH v1 0/4] regmap: a small set of cleanups Andy Shevchenko
2026-11-10  9:36 ` Andy Shevchenko [this message]
2026-11-10  9:37 ` [PATCH v1 2/4] regmap: Drop never used devm_regmap_*_free() APIs Andy Shevchenko
2026-11-10 10:19   ` Peng Fan
2026-11-10  9:37 ` [PATCH v1 3/4] regmap: Defer assignments to the later in some cases Andy Shevchenko
2026-11-10 10:20   ` Peng Fan
2026-11-10  9:37 ` [PATCH v1 4/4] regmap: Drop duplicate ret assignment Andy Shevchenko
2026-11-10 10:22   ` Peng Fan
  -- strict thread matches above, loose matches on Subject: below --
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261110093820.454682-2-andriy.shevchenko@linux.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=broonie@kernel.org \
    --cc=dakr@kernel.org \
    --cc=driver-core@lists.linux.dev \
    --cc=gregkh@linuxfoundation.org \
    --cc=johan@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®