From: Linus Walleij Date: Tue, 23 Aug 2022 13:57:00 +0000 (+0200) Subject: regmap: check right noinc bounds in debug print X-Git-Tag: v6.6.17~6501^2~8 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b7059927c3e32c96d2ff50c206549d8fac0ba69e;p=platform%2Fkernel%2Flinux-rpi.git regmap: check right noinc bounds in debug print 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 Signed-off-by: Linus Walleij Link: https://lore.kernel.org/r/20220823135700.265019-1-linus.walleij@linaro.org Signed-off-by: Mark Brown --- diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index 63d9c6a..c6d6d53 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(",");