From: Elkin Cruz <elkin@google.com>
To: Linus Walleij <linusw@kernel.org>,
Thierry Reding <thierry.reding@kernel.org>,
Jonathan Hunter <jonathanh@nvidia.com>
Cc: linux-gpio@vger.kernel.org, linux-tegra@vger.kernel.org,
Aaron Kling <webgeek1234@gmail.com>,
linux-kernel@vger.kernel.org, llvm@lists.linux.dev,
irogers@google.com, Elkin Cruz <elkin@google.com>
Subject: [PATCH 2/2] pinctrl: tegra: Add register bank bounds checks
Date: Wed, 25 Nov 2026 22:25:49 +0000 [thread overview]
Message-ID: <20261125222549.1447825-3-elkin@google.com> (raw)
In-Reply-To: <20261125222549.1447825-1-elkin@google.com>
Add defensive bounds checks on the register bank index in
tegra_pinconf_reg(), pmx_readl(), and pmx_writel() (using
WARN_ON_ONCE()) so misconfigured pin group tables cannot index past
pmx->regs[pmx->nbanks].
Signed-off-by: Elkin Cruz <elkin@google.com>
---
drivers/pinctrl/tegra/pinctrl-tegra.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/pinctrl/tegra/pinctrl-tegra.c b/drivers/pinctrl/tegra/pinctrl-tegra.c
index 51684c5dda34..c0b584d37a8e 100644
--- a/drivers/pinctrl/tegra/pinctrl-tegra.c
+++ b/drivers/pinctrl/tegra/pinctrl-tegra.c
@@ -30,11 +30,17 @@
static inline u32 pmx_readl(struct tegra_pmx *pmx, u32 bank, u32 reg)
{
+ if (WARN_ON_ONCE(bank >= pmx->nbanks))
+ return 0;
+
return readl(pmx->regs[bank] + reg);
}
static inline void pmx_writel(struct tegra_pmx *pmx, u32 val, u32 bank, u32 reg)
{
+ if (WARN_ON_ONCE(bank >= pmx->nbanks))
+ return;
+
writel_relaxed(val, pmx->regs[bank] + reg);
/* make sure pinmux register write completed */
pmx_readl(pmx, bank, reg);
@@ -525,7 +531,7 @@ static int tegra_pinconf_reg(struct tegra_pmx *pmx,
return -ENOTSUPP;
}
- if (*reg < 0 || *bit < 0) {
+ if (*reg < 0 || *bit < 0 || *bank < 0 || *bank >= pmx->nbanks) {
if (report_err) {
const char *prop = "unknown";
int i;
--
2.56.1.839.g22a8290db9-goog
next prev parent reply other threads:[~2026-11-25 22:26 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 22:25 [PATCH 0/2] pinctrl: tegra: fix Tegra186 AON bank index and add bank bounds checks Elkin Cruz
2026-11-25 22:25 ` [PATCH 1/2] pinctrl: tegra186: Fix register bank for AON drive pin groups Elkin Cruz
2026-11-25 22:25 ` Elkin Cruz [this message]
2026-11-25 22:51 ` [PATCH 2/2] pinctrl: tegra: Add register bank bounds checks sashiko-bot
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=20261125222549.1447825-3-elkin@google.com \
--to=elkin@google.com \
--cc=irogers@google.com \
--cc=jonathanh@nvidia.com \
--cc=linusw@kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=thierry.reding@kernel.org \
--cc=webgeek1234@gmail.com \
/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.