From: Qinguang Xu via B4 Relay <devnull+guang.cy2023.gmail.com@kernel.org>
To: Mark Brown <broonie@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Danilo Krummrich <dakr@kernel.org>
Cc: linux-kernel@vger.kernel.org, driver-core@lists.linux.dev,
Qinguang Xu <guang.cy2023@gmail.com>
Subject: [PATCH] regmap: irq: fix incorrect index calculation for read_sub_irq_data()
Date: Tue, 20 Oct 2026 21:39:06 +0800 [thread overview]
Message-ID: <20261020-debug-v1-1-44e0491ede30@gmail.com> (raw)
From: Qinguang Xu <guang.cy2023@gmail.com>
While working on a PMIC driver that utilizes num_main_regs > 1, this
issue was noticed. Currently, no in-tree driver sets `num_main_regs >
1`, so this bug has not been triggered in practice.
Pass the global index calculated with `i` instead of the local bit
offset `b` to read_sub_irq_data().
Fix an off-by-one error in the index bounds check.
This patch has been compile-tested only.
Signed-off-by: Qinguang Xu <guang.cy2023@gmail.com>
---
drivers/base/regmap/regmap-irq.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/base/regmap/regmap-irq.c b/drivers/base/regmap/regmap-irq.c
index 99b55b105..e151c6222 100644
--- a/drivers/base/regmap/regmap-irq.c
+++ b/drivers/base/regmap/regmap-irq.c
@@ -398,14 +398,14 @@ static int read_irq_data(struct regmap_irq_chip_data *data)
/* Read sub registers with active IRQs */
for (i = 0; i < chip->num_main_regs; i++) {
- unsigned int b;
+ unsigned int b, index;
const unsigned long mreg = data->main_status_buf[i];
for_each_set_bit(b, &mreg, map->format.val_bytes * 8) {
- if (i * map->format.val_bytes * 8 + b >
- max_main_bits)
+ index = i * map->format.val_bytes * 8 + b;
+ if (index >= max_main_bits)
break;
- ret = read_sub_irq_data(data, b);
+ ret = read_sub_irq_data(data, index);
if (ret != 0) {
dev_err(map->dev, "Failed to read IRQ status %d\n", ret);
---
base-commit: 4056b3c9d3c92ea45955641dbafeb9b960e146ef
change-id: 20261020-debug-6bee55638a91
Best regards,
--
Qinguang Xu <guang.cy2023@gmail.com>
WARNING: multiple messages have this Message-ID (diff)
From: Qinguang Xu <guang.cy2023@gmail.com>
To: Mark Brown <broonie@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Danilo Krummrich <dakr@kernel.org>
Cc: linux-kernel@vger.kernel.org, driver-core@lists.linux.dev,
Qinguang Xu <guang.cy2023@gmail.com>
Subject: [PATCH] regmap: irq: fix incorrect index calculation for read_sub_irq_data()
Date: Tue, 20 Oct 2026 21:39:06 +0800 [thread overview]
Message-ID: <20261020-debug-v1-1-44e0491ede30@gmail.com> (raw)
While working on a PMIC driver that utilizes num_main_regs > 1, this
issue was noticed. Currently, no in-tree driver sets `num_main_regs >
1`, so this bug has not been triggered in practice.
Pass the global index calculated with `i` instead of the local bit
offset `b` to read_sub_irq_data().
Fix an off-by-one error in the index bounds check.
This patch has been compile-tested only.
Signed-off-by: Qinguang Xu <guang.cy2023@gmail.com>
---
drivers/base/regmap/regmap-irq.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/base/regmap/regmap-irq.c b/drivers/base/regmap/regmap-irq.c
index 99b55b105..e151c6222 100644
--- a/drivers/base/regmap/regmap-irq.c
+++ b/drivers/base/regmap/regmap-irq.c
@@ -398,14 +398,14 @@ static int read_irq_data(struct regmap_irq_chip_data *data)
/* Read sub registers with active IRQs */
for (i = 0; i < chip->num_main_regs; i++) {
- unsigned int b;
+ unsigned int b, index;
const unsigned long mreg = data->main_status_buf[i];
for_each_set_bit(b, &mreg, map->format.val_bytes * 8) {
- if (i * map->format.val_bytes * 8 + b >
- max_main_bits)
+ index = i * map->format.val_bytes * 8 + b;
+ if (index >= max_main_bits)
break;
- ret = read_sub_irq_data(data, b);
+ ret = read_sub_irq_data(data, index);
if (ret != 0) {
dev_err(map->dev, "Failed to read IRQ status %d\n", ret);
---
base-commit: 4056b3c9d3c92ea45955641dbafeb9b960e146ef
change-id: 20261020-debug-6bee55638a91
Best regards,
--
Qinguang Xu <guang.cy2023@gmail.com>
next reply other threads:[~2026-10-20 13:40 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-20 13:39 Qinguang Xu via B4 Relay [this message]
2026-10-20 13:39 ` [PATCH] regmap: irq: fix incorrect index calculation for read_sub_irq_data() Qinguang Xu
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=20261020-debug-v1-1-44e0491ede30@gmail.com \
--to=devnull+guang.cy2023.gmail.com@kernel.org \
--cc=broonie@kernel.org \
--cc=dakr@kernel.org \
--cc=driver-core@lists.linux.dev \
--cc=gregkh@linuxfoundation.org \
--cc=guang.cy2023@gmail.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.