[PATCH] regmap: check right noinc bounds in debug print

Linus Walleij posted 1 patch 3 years, 7 months ago
drivers/base/regmap/regmap.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
[PATCH] regmap: check right noinc bounds in debug print
Posted by Linus Walleij 3 years, 7 months ago
We were using the wrong bound in the debug prints: this
needs to be the number of elements, not the number of bytes,
since we're indexing into an element-size typed array.

Fixes: c20cc099b30a ("regmap: Support accelerated noinc operations")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/base/regmap/regmap.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index 41ff9f18b6a3..f8815a8fedcb 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -2193,7 +2193,7 @@ static int regmap_noinc_readwrite(struct regmap *map, unsigned int reg,
 
 	if (!ret && regmap_should_log(map)) {
 		dev_info(map->dev, "%x %s [", reg, write ? "<=" : "=>");
-		for (i = 0; i < val_len; i++) {
+		for (i = 0; i < val_count; i++) {
 			switch (val_bytes) {
 			case 1:
 				pr_cont("%x", u8p[i]);
@@ -2212,7 +2212,7 @@ static int regmap_noinc_readwrite(struct regmap *map, unsigned int reg,
 			default:
 				break;
 			}
-			if (i == (val_len - 1))
+			if (i == (val_count - 1))
 				pr_cont("]\n");
 			else
 				pr_cont(",");
-- 
2.37.2
Re: [PATCH] regmap: check right noinc bounds in debug print
Posted by Mark Brown 3 years, 7 months ago
On Tue, 23 Aug 2022 15:57:00 +0200, Linus Walleij wrote:
> We were using the wrong bound in the debug prints: this
> needs to be the number of elements, not the number of bytes,
> since we're indexing into an element-size typed array.
> 
> 

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git for-next

Thanks!

[1/1] regmap: check right noinc bounds in debug print
      commit: b7059927c3e32c96d2ff50c206549d8fac0ba69e

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