* [PATCH 00/10] pinctrl: Fix out-of-bounds accesses, divide-by-zero, and error handling
@ 2026-11-03 21:29 Lee Jones
2026-11-03 21:29 ` [PATCH 01/10] pinctrl: sunxi: Fix out-of-bounds irq_bank index when first bank has no IRQs Lee Jones
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: Lee Jones @ 2026-11-03 21:29 UTC (permalink / raw)
To: lee, Matthias Brugger, AngeloGioacchino Del Regno, linux-kernel,
linux-arm-kernel, linux-mediatek
Cc: Aaron Kling, Ajay Kishore, Andreas Färber, Andreas Kemnade,
Andre Przywara, Bartosz Golaszewski, Bjorn Andersson,
Chen-Yu Tsai, Christian Marangi, Daniel Golle, Hao Chang,
H. Nikolaus Schaller, James Tai, Jernej Skrabec, Jonathan Hunter,
Linus Walleij, linux-arm-msm, linux-gpio, linux-mips,
linux-realtek-soc, linux-sunxi, linux-tegra, Paul Boddie,
Paul Cercueil, Qingliang Li, Rob Herring, Ryder.Lee, Sam Shih,
Samuel Holland, Sean Wang, Thierry Reding, Tzuyi Chang,
Yu-Chun Lin, zhouyanjie
These issues were reported by Sashiko.
Cc: Aaron Kling <webgeek1234@gmail.com>
Cc: Ajay Kishore <akisho@codeaurora.org>
Cc: "Andreas Färber" <afaerber@suse.com>
Cc: Andreas Kemnade <andreas@kemnade.info>
Cc: Andre Przywara <andre.przywara@arm.com>
Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Cc: Bartosz Golaszewski <brgl@kernel.org>
Cc: Bjorn Andersson <andersson@kernel.org>
Cc: Chen-Yu Tsai <wens@kernel.org>
Cc: Christian Marangi <ansuelsmth@gmail.com>
Cc: Daniel Golle <daniel@makrotopia.org>
Cc: Hao Chang <ot_chhao.chang@mediatek.com>
Cc: "H. Nikolaus Schaller" <hns@goldelico.com>
Cc: James Tai <james.tai@realtek.com>
Cc: Jernej Skrabec <jernej.skrabec@gmail.com>
Cc: Jonathan Hunter <jonathanh@nvidia.com>
Cc: Linus Walleij <linusw@kernel.org>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-arm-msm@vger.kernel.org
Cc: linux-gpio@vger.kernel.org
Cc: linux-mediatek@lists.infradead.org
Cc: linux-mips@vger.kernel.org
Cc: linux-realtek-soc@lists.infradead.org
Cc: linux-sunxi@lists.linux.dev
Cc: linux-tegra@vger.kernel.org
Cc: Matthias Brugger <matthias.bgg@gmail.com>
Cc: Paul Boddie <paul@boddie.org.uk>
Cc: Paul Cercueil <paul@crapouillou.net>
Cc: Qingliang Li <qingliang.li@mediatek.com>
Cc: Rob Herring <robh@kernel.org>
Cc: "Ryder.Lee" <ryder.lee@mediatek.com>
Cc: Sam Shih <sam.shih@mediatek.com>
Cc: Samuel Holland <samuel@sholland.org>
Cc: Sean Wang <sean.wang@kernel.org>
Cc: Thierry Reding <thierry.reding@kernel.org>
Cc: Tzuyi Chang <tychang@realtek.com>
Cc: Yu-Chun Lin <eleanor.lin@realtek.com>
Cc: zhouyanjie@wanyeetech.com
Lee Jones (10):
pinctrl: sunxi: Fix out-of-bounds irq_bank index when first bank has
no IRQs
pinctrl: tegra186: Fix out-of-bounds register bank index for AON drive
groups
pinctrl: ingenic: Fix element type of x1600_sfc_funcs array
pinctrl: mediatek: mt7981: Add missing entries to mt7981_ant_sel_funcs
pinctrl: realtek: Prevent out-of-bounds access in
rtd_pinctrl_find_config()
pinctrl: realtek: Fix bit shift when configuring RTD_HIGH_VIL
pinctrl: realtek: Initialise omitted offset fields to NA in config
macros
pinctrl: mediatek: Clean up partially initialised hw->eint on error
pinctrl: mediatek: Prevent divide-by-zero for pins with fixed drive
strength
pinctrl: qcom: Check qcom_scm_io_readl() return value in
msm_gpio_irq_set_type()
drivers/pinctrl/mediatek/pinctrl-mt7981.c | 2 +-
.../pinctrl/mediatek/pinctrl-mtk-common-v2.c | 24 ++++-
drivers/pinctrl/pinctrl-ingenic.c | 2 +-
drivers/pinctrl/qcom/pinctrl-msm.c | 10 +-
drivers/pinctrl/realtek/pinctrl-rtd.c | 5 +-
drivers/pinctrl/realtek/pinctrl-rtd.h | 5 +
drivers/pinctrl/sunxi/pinctrl-sunxi-dt.c | 11 +-
drivers/pinctrl/tegra/pinctrl-tegra186.c | 102 +++++++++---------
8 files changed, 93 insertions(+), 68 deletions(-)
--
2.56.0.385.gac671c819a-goog
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 01/10] pinctrl: sunxi: Fix out-of-bounds irq_bank index when first bank has no IRQs
2026-11-03 21:29 [PATCH 00/10] pinctrl: Fix out-of-bounds accesses, divide-by-zero, and error handling Lee Jones
@ 2026-11-03 21:29 ` Lee Jones
2026-11-03 21:29 ` [PATCH 04/10] pinctrl: mediatek: mt7981: Add missing entries to mt7981_ant_sel_funcs Lee Jones
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Lee Jones @ 2026-11-03 21:29 UTC (permalink / raw)
To: lee, Linus Walleij, Chen-Yu Tsai, Jernej Skrabec, Samuel Holland,
Andre Przywara, linux-gpio, linux-arm-kernel, linux-sunxi,
linux-kernel
Cc: stable
In prepare_function_table(), irq_bank and last_bank are initialised to 0
and last_bank is updated on every bank regardless of whether it supports
interrupts. On SoCs where bank 0 (PA) has no pins or does not support
interrupts (such as Allwinner A523 and A733), the first IRQ-capable bank
has bank > 0, which causes irq_bank to be incremented to 1 instead of
starting at 0. As a result, the final IRQ bank receives irq_bank equal
to desc->irq_banks and writes out-of-bounds past pctl->irq_array during
sunxi_pinctrl_build_state().
Initialise irq_bank and last_bank to -1 and only update last_bank when
processing an IRQ-capable bank so that irq_bank always starts at 0 and
increments sequentially across IRQ-capable banks.
Fixes: f5e2cd34b12f ("pinctrl: sunxi: allow reading mux values from DT")
Closes: https://sashiko.dev/#/bug/linux-9c4dd832-02d4-4096-9e91-a03c1d4d85b3
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
drivers/pinctrl/sunxi/pinctrl-sunxi-dt.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi-dt.c b/drivers/pinctrl/sunxi/pinctrl-sunxi-dt.c
index 8bcd566593ae..79ca1a7c4837 100644
--- a/drivers/pinctrl/sunxi/pinctrl-sunxi-dt.c
+++ b/drivers/pinctrl/sunxi/pinctrl-sunxi-dt.c
@@ -208,8 +208,8 @@ static int prepare_function_table(struct device *dev, struct device_node *pnode,
* Assign the function's memory and fill in GPIOs, IRQ and a sentinel.
* The extra functions will be filled in later.
*/
- irq_bank = 0;
- last_bank = 0;
+ irq_bank = -1;
+ last_bank = -1;
for (i = 0; i < npins; i++) {
struct sunxi_desc_pin *pin = &pins[i];
int bank = (pin->pin.number - pin_base) / PINS_PER_BANK;
@@ -222,17 +222,16 @@ static int prepare_function_table(struct device *dev, struct device_node *pnode,
func[1].muxval = 1;
if (irq_mux) {
- if (bank > last_bank)
+ if (bank > last_bank) {
irq_bank++;
+ last_bank = bank;
+ }
func[lastfunc].muxval = irq_mux;
func[lastfunc].irqbank = irq_bank;
func[lastfunc].irqnum = pin->pin.number % PINS_PER_BANK;
func[lastfunc].name = "irq";
}
- if (bank > last_bank)
- last_bank = bank;
-
pin->functions = func;
/* Skip over the other needed functions and the sentinel. */
--
2.56.0.385.gac671c819a-goog
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 04/10] pinctrl: mediatek: mt7981: Add missing entries to mt7981_ant_sel_funcs
2026-11-03 21:29 [PATCH 00/10] pinctrl: Fix out-of-bounds accesses, divide-by-zero, and error handling Lee Jones
2026-11-03 21:29 ` [PATCH 01/10] pinctrl: sunxi: Fix out-of-bounds irq_bank index when first bank has no IRQs Lee Jones
@ 2026-11-03 21:29 ` Lee Jones
2026-11-03 21:29 ` [PATCH 05/10] pinctrl: realtek: Prevent out-of-bounds access in rtd_pinctrl_find_config() Lee Jones
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Lee Jones @ 2026-11-03 21:29 UTC (permalink / raw)
To: lee, Sean Wang, Linus Walleij, Matthias Brugger,
AngeloGioacchino Del Regno, Sam Shih, Rob Herring, Daniel Golle,
linux-mediatek, linux-gpio, linux-kernel, linux-arm-kernel
Cc: stable
mt7981_ant_sel_pins[] defines 14 pins (pins 14..25, 34, and 35), all of
which select ANT_SEL at function mux mode 6, but mt7981_ant_sel_funcs[]
only contains 12 entries. When mtk_pinmux_set_mux() iterates over
grp->num_pins (14), it reads two int elements past the end of
mt7981_ant_sel_funcs[].
Add the two missing mode 6 entries to mt7981_ant_sel_funcs[] so its
length matches mt7981_ant_sel_pins[].
Fixes: 6c83b2d94fcc ("pinctrl: add mt7981 pinctrl driver")
Closes: https://sashiko.dev/#/bug/linux-6233f285-1487-4d2d-afe3-d4ce3c445054
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
drivers/pinctrl/mediatek/pinctrl-mt7981.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/pinctrl/mediatek/pinctrl-mt7981.c b/drivers/pinctrl/mediatek/pinctrl-mt7981.c
index 2325cc8b9345..62fec909408b 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mt7981.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mt7981.c
@@ -800,7 +800,7 @@ static int mt7981_mt7531_int_funcs[] = { 1, };
/* ANT_SEL */
static int mt7981_ant_sel_pins[] = { 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 34, 35 };
-static int mt7981_ant_sel_funcs[] = { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 };
+static int mt7981_ant_sel_funcs[] = { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 };
static const struct group_desc mt7981_groups[] = {
/* @GPIO(0,1): WA_AICE(2) */
--
2.56.0.385.gac671c819a-goog
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 05/10] pinctrl: realtek: Prevent out-of-bounds access in rtd_pinctrl_find_config()
2026-11-03 21:29 [PATCH 00/10] pinctrl: Fix out-of-bounds accesses, divide-by-zero, and error handling Lee Jones
2026-11-03 21:29 ` [PATCH 01/10] pinctrl: sunxi: Fix out-of-bounds irq_bank index when first bank has no IRQs Lee Jones
2026-11-03 21:29 ` [PATCH 04/10] pinctrl: mediatek: mt7981: Add missing entries to mt7981_ant_sel_funcs Lee Jones
@ 2026-11-03 21:29 ` Lee Jones
2026-11-03 21:29 ` [PATCH 06/10] pinctrl: realtek: Fix bit shift when configuring RTD_HIGH_VIL Lee Jones
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Lee Jones @ 2026-11-03 21:29 UTC (permalink / raw)
To: lee, James Tai, Yu-Chun Lin, Andreas Färber, Linus Walleij,
Tzuyi Chang, linux-arm-kernel, linux-realtek-soc, linux-gpio,
linux-kernel
Cc: stable
Several Realtek SoC pin configuration tables (such as rtd1319d_iso_configs,
rtd1619b_iso_configs, and the rtd1625 config tables) omit trailing pins
that do not support pin configuration, making data->info->num_configs
smaller than data->info->num_pins. Because rtd_pinctrl_find_config()
indexes data->info->configs[pin] without checking data->info->num_configs,
requesting pin configuration on a trailing pin reads out-of-bounds memory.
Check that pin is less than data->info->num_configs before indexing
data->info->configs[].
Fixes: e99ce78030db ("pinctrl: realtek: Add common pinctrl driver for Realtek DHC RTD SoCs")
Closes: https://sashiko.dev/#/bug/linux-60e13761-fd9e-4fd3-826a-47344f36d4fa
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
drivers/pinctrl/realtek/pinctrl-rtd.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/pinctrl/realtek/pinctrl-rtd.c b/drivers/pinctrl/realtek/pinctrl-rtd.c
index 60222339726b..2b877099ec85 100644
--- a/drivers/pinctrl/realtek/pinctrl-rtd.c
+++ b/drivers/pinctrl/realtek/pinctrl-rtd.c
@@ -252,6 +252,9 @@ static const struct pinctrl_pin_desc
static const struct rtd_pin_config_desc
*rtd_pinctrl_find_config(struct rtd_pinctrl *data, unsigned int pin)
{
+ if (pin >= data->info->num_configs)
+ return NULL;
+
if (data->info->configs[pin].name)
return &data->info->configs[pin];
--
2.56.0.385.gac671c819a-goog
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 06/10] pinctrl: realtek: Fix bit shift when configuring RTD_HIGH_VIL
2026-11-03 21:29 [PATCH 00/10] pinctrl: Fix out-of-bounds accesses, divide-by-zero, and error handling Lee Jones
` (2 preceding siblings ...)
2026-11-03 21:29 ` [PATCH 05/10] pinctrl: realtek: Prevent out-of-bounds access in rtd_pinctrl_find_config() Lee Jones
@ 2026-11-03 21:29 ` Lee Jones
2026-11-03 21:29 ` [PATCH 07/10] pinctrl: realtek: Initialise omitted offset fields to NA in config macros Lee Jones
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Lee Jones @ 2026-11-03 21:29 UTC (permalink / raw)
To: lee, James Tai, Yu-Chun Lin, Andreas Färber, Linus Walleij,
Tzuyi Chang, linux-arm-kernel, linux-realtek-soc, linux-gpio,
linux-kernel
Cc: stable
In rtd_pconf_parse_conf(), the RTD_HIGH_VIL case prepares mask as
BIT(hvil_off) for regmap_update_bits(), but sets val = 1 without
shifting it to hvil_off. Whenever hvil_off is non-zero,
regmap_update_bits() masks val with BIT(hvil_off) and clears the high
VIL bit instead of setting it.
Set val to BIT(hvil_off) so that the target bit is set as intended.
Fixes: dcc9334435b0 ("pinctrl: realtek: add support for slew rate, input voltage and high VIL")
Closes: https://sashiko.dev/#/bug/linux-e7077311-3f30-4b77-844b-1447519d0c84
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
drivers/pinctrl/realtek/pinctrl-rtd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/pinctrl/realtek/pinctrl-rtd.c b/drivers/pinctrl/realtek/pinctrl-rtd.c
index 2b877099ec85..72773600303b 100644
--- a/drivers/pinctrl/realtek/pinctrl-rtd.c
+++ b/drivers/pinctrl/realtek/pinctrl-rtd.c
@@ -473,7 +473,7 @@ static int rtd_pconf_parse_conf(struct rtd_pinctrl *data,
hvil_off = config_desc->base_bit + config_desc->hvil_offset;
reg_off = config_desc->reg_offset;
mask = BIT(hvil_off);
- val = 1;
+ val = BIT(hvil_off);
break;
case RTD_DRIVE_STRENGTH_P:
--
2.56.0.385.gac671c819a-goog
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 07/10] pinctrl: realtek: Initialise omitted offset fields to NA in config macros
2026-11-03 21:29 [PATCH 00/10] pinctrl: Fix out-of-bounds accesses, divide-by-zero, and error handling Lee Jones
` (3 preceding siblings ...)
2026-11-03 21:29 ` [PATCH 06/10] pinctrl: realtek: Fix bit shift when configuring RTD_HIGH_VIL Lee Jones
@ 2026-11-03 21:29 ` Lee Jones
2026-11-03 21:29 ` [PATCH 08/10] pinctrl: mediatek: Clean up partially initialised hw->eint on error Lee Jones
2026-11-03 21:29 ` [PATCH 09/10] pinctrl: mediatek: Prevent divide-by-zero for pins with fixed drive strength Lee Jones
6 siblings, 0 replies; 8+ messages in thread
From: Lee Jones @ 2026-11-03 21:29 UTC (permalink / raw)
To: lee, James Tai, Yu-Chun Lin, Andreas Färber, Linus Walleij,
Tzuyi Chang, linux-arm-kernel, linux-realtek-soc, linux-gpio,
linux-kernel
Cc: stable
The Realtek pinctrl driver uses NA (0xffffffff) as the sentinel for
unsupported pin configuration features. However, RTK_PIN_CONFIG omits
input_volt_offset, slew_rate_offset, and hvil_offset, and
RTK_PIN_CONFIG_V2 omits slew_rate_offset and hvil_offset. Because C99
designated initialisers zero-initialise omitted members, those fields
default to 0 instead of NA, causing rtd_pconf_parse_conf() to treat
unsupported features as valid at bit offset base_bit + 0 and corrupt
adjacent register bits.
Explicitly initialise the omitted offset fields to NA in RTK_PIN_CONFIG
and RTK_PIN_CONFIG_V2.
Fixes: dcc9334435b0 ("pinctrl: realtek: add support for slew rate, input voltage and high VIL")
Fixes: e309dbd523b8 ("pinctrl: realtek: add rtd1625 pinctrl driver")
Closes: https://sashiko.dev/#/bug/linux-fbd0bf54-6dba-4652-9418-270b11fb6d8b
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
drivers/pinctrl/realtek/pinctrl-rtd.h | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/pinctrl/realtek/pinctrl-rtd.h b/drivers/pinctrl/realtek/pinctrl-rtd.h
index 77c30ea76443..86db54ea3ce8 100644
--- a/drivers/pinctrl/realtek/pinctrl-rtd.h
+++ b/drivers/pinctrl/realtek/pinctrl-rtd.h
@@ -96,6 +96,9 @@ struct rtd_pin_reg_list {
.smt_offset = _smt_off, \
.power_offset = _pow_off, \
.curr_type = _curr_type, \
+ .input_volt_offset = NA, \
+ .slew_rate_offset = NA, \
+ .hvil_offset = NA, \
}
#define RTK_PIN_CONFIG_V2(_name, _reg_off, _base_bit, _pud_en_off, \
@@ -112,6 +115,8 @@ struct rtd_pin_reg_list {
.power_offset = _pow_off, \
.input_volt_offset = _input_volt_off, \
.curr_type = _curr_type, \
+ .slew_rate_offset = NA, \
+ .hvil_offset = NA, \
}
#define RTK_PIN_CONFIG_I2C(_name, _reg_off, _base_bit, _pud_en_off, \
--
2.56.0.385.gac671c819a-goog
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 08/10] pinctrl: mediatek: Clean up partially initialised hw->eint on error
2026-11-03 21:29 [PATCH 00/10] pinctrl: Fix out-of-bounds accesses, divide-by-zero, and error handling Lee Jones
` (4 preceding siblings ...)
2026-11-03 21:29 ` [PATCH 07/10] pinctrl: realtek: Initialise omitted offset fields to NA in config macros Lee Jones
@ 2026-11-03 21:29 ` Lee Jones
2026-11-03 21:29 ` [PATCH 09/10] pinctrl: mediatek: Prevent divide-by-zero for pins with fixed drive strength Lee Jones
6 siblings, 0 replies; 8+ messages in thread
From: Lee Jones @ 2026-11-03 21:29 UTC (permalink / raw)
To: lee, Sean Wang, Linus Walleij, Matthias Brugger,
AngeloGioacchino Del Regno, Hao Chang, Qingliang Li,
linux-mediatek, linux-gpio, linux-kernel, linux-arm-kernel
Cc: stable
In mtk_build_eint(), if of_property_count_strings() fails or
hw->eint->nbase is non-positive, the function returns -EINVAL directly
after allocating hw->eint without jumping to err_free_base. Because
callers such as mtk_paris_pinctrl_probe() and mtk_moore_pinctrl_probe()
log a warning and continue probing when mtk_build_eint() fails, leaving
hw->eint non-NULL with hw->eint->hw unset causes subsequent GPIO or
suspend/resume callbacks to dereference a NULL pointer inside
mtk_eint_do_suspend() or mtk_gpio_to_irq().
Jump to err_free_base on both error paths so hw->eint is freed and
reset to NULL.
Fixes: 3ef9f710efcb ("pinctrl: mediatek: Add EINT support for multiple addresses")
Closes: https://sashiko.dev/#/bug/linux-0689c07e-ef74-4bc2-b5de-bd2f361124bd
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
index faa6dbf0f635..aa15c9e047d8 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
@@ -382,12 +382,16 @@ int mtk_build_eint(struct mtk_pinctrl *hw, struct platform_device *pdev)
return -ENOMEM;
count_reg_names = of_property_count_strings(np, "reg-names");
- if (count_reg_names < 0)
- return -EINVAL;
+ if (count_reg_names < 0) {
+ ret = -EINVAL;
+ goto err_free_base;
+ }
hw->eint->nbase = count_reg_names - (int)hw->soc->nbase_names;
- if (hw->eint->nbase <= 0)
- return -EINVAL;
+ if (hw->eint->nbase <= 0) {
+ ret = -EINVAL;
+ goto err_free_base;
+ }
hw->eint->base = devm_kmalloc_array(&pdev->dev, hw->eint->nbase,
sizeof(*hw->eint->base), GFP_KERNEL | __GFP_ZERO);
--
2.56.0.385.gac671c819a-goog
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 09/10] pinctrl: mediatek: Prevent divide-by-zero for pins with fixed drive strength
2026-11-03 21:29 [PATCH 00/10] pinctrl: Fix out-of-bounds accesses, divide-by-zero, and error handling Lee Jones
` (5 preceding siblings ...)
2026-11-03 21:29 ` [PATCH 08/10] pinctrl: mediatek: Clean up partially initialised hw->eint on error Lee Jones
@ 2026-11-03 21:29 ` Lee Jones
6 siblings, 0 replies; 8+ messages in thread
From: Lee Jones @ 2026-11-03 21:29 UTC (permalink / raw)
To: lee, Sean Wang, Linus Walleij, Matthias Brugger,
AngeloGioacchino Del Regno, Ryder.Lee, linux-mediatek, linux-gpio,
linux-kernel, linux-arm-kernel
Cc: stable
mtk_drive[] only defines entries for DRV_GRP0 (1) through DRV_GRP4 (5),
leaving mtk_drive[DRV_FIXED] (0) zero-initialised with min = 0, max = 0,
step = 0, and scal = 0. If mtk_pinconf_drive_set() or
mtk_pinconf_drive_set_rev1() is called with arg = 0 on a pin with
drv_n == DRV_FIXED, the range check (0 >= 0 && 0 <= 0) succeeds and
!(arg % tb->step) divides by zero. Similarly, mtk_pinconf_drive_get()
and mtk_pinconf_drive_get_rev1() divide by tb->scal (0) if the pin has
drive register fields defined.
Return -ENOTSUPP immediately when desc->drv_n == DRV_FIXED.
Fixes: c28321979ba8 ("pinctrl: mediatek: add driving strength related support to pinctrl-mtk-common-v2.c")
Closes: https://sashiko.dev/#/bug/linux-d3852d37-6806-4c41-a493-f249dd59d0c6
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
index aa15c9e047d8..1243862983b9 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
@@ -1040,6 +1040,9 @@ int mtk_pinconf_drive_set(struct mtk_pinctrl *hw,
const struct mtk_drive_desc *tb;
int err = -ENOTSUPP;
+ if (desc->drv_n == DRV_FIXED)
+ return -ENOTSUPP;
+
tb = &mtk_drive[desc->drv_n];
/* 4mA when (e8, e4) = (0, 0)
* 8mA when (e8, e4) = (0, 1)
@@ -1069,6 +1072,9 @@ int mtk_pinconf_drive_get(struct mtk_pinctrl *hw,
const struct mtk_drive_desc *tb;
int err, val1, val2;
+ if (desc->drv_n == DRV_FIXED)
+ return -ENOTSUPP;
+
tb = &mtk_drive[desc->drv_n];
err = mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_E4, &val1);
@@ -1095,6 +1101,9 @@ int mtk_pinconf_drive_set_rev1(struct mtk_pinctrl *hw,
const struct mtk_drive_desc *tb;
int err = -ENOTSUPP;
+ if (desc->drv_n == DRV_FIXED)
+ return -ENOTSUPP;
+
tb = &mtk_drive[desc->drv_n];
if ((arg >= tb->min && arg <= tb->max) && !(arg % tb->step)) {
@@ -1116,6 +1125,9 @@ int mtk_pinconf_drive_get_rev1(struct mtk_pinctrl *hw,
const struct mtk_drive_desc *tb;
int err, val1;
+ if (desc->drv_n == DRV_FIXED)
+ return -ENOTSUPP;
+
tb = &mtk_drive[desc->drv_n];
err = mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_DRV, &val1);
--
2.56.0.385.gac671c819a-goog
^ permalink raw reply related [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-11-03 21:31 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-03 21:29 [PATCH 00/10] pinctrl: Fix out-of-bounds accesses, divide-by-zero, and error handling Lee Jones
2026-11-03 21:29 ` [PATCH 01/10] pinctrl: sunxi: Fix out-of-bounds irq_bank index when first bank has no IRQs Lee Jones
2026-11-03 21:29 ` [PATCH 04/10] pinctrl: mediatek: mt7981: Add missing entries to mt7981_ant_sel_funcs Lee Jones
2026-11-03 21:29 ` [PATCH 05/10] pinctrl: realtek: Prevent out-of-bounds access in rtd_pinctrl_find_config() Lee Jones
2026-11-03 21:29 ` [PATCH 06/10] pinctrl: realtek: Fix bit shift when configuring RTD_HIGH_VIL Lee Jones
2026-11-03 21:29 ` [PATCH 07/10] pinctrl: realtek: Initialise omitted offset fields to NA in config macros Lee Jones
2026-11-03 21:29 ` [PATCH 08/10] pinctrl: mediatek: Clean up partially initialised hw->eint on error Lee Jones
2026-11-03 21:29 ` [PATCH 09/10] pinctrl: mediatek: Prevent divide-by-zero for pins with fixed drive strength Lee Jones
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox