[PATCH] mfd: stmpe: Disable regulators on probe failure

From: Wang Haoran

Date: Thu Nov 19 2026 - 03:15:53 EST


stmpe_probe() enables the VCC and VIO regulators early in probe, but they
are only ever disabled by stmpe_remove() on the successful unbind path.
Every failure return in between leaves both rails enabled, and a later
-EPROBE_DEFER retry enables them again, so the enable counts grow on each
failed probe and _regulator_put() warns on each leaked enable.

Register a devm action right after the enables that disables any regulator
still enabled when the probe fails or the device is unbound, mirroring what
stmpe_remove() already does.

Signed-off-by: Wang Haoran <wanghr2026@xxxxxxxxxxxxxxxxxx>
Fixes: 9c9e321455fb ("mfd: stmpe: add optional regulators")
---

diff --git a/drivers/mfd/stmpe.c b/drivers/mfd/stmpe.c
index fd51ba74275c..9475a257acdb 100644
--- a/drivers/mfd/stmpe.c
+++ b/drivers/mfd/stmpe.c
@@ -1363,6 +1363,16 @@ static void stmpe_of_probe(struct stmpe_platform_data *pdata,
}

/* Called from client specific probe routines */
+static void stmpe_disable_regulators(void *data)
+{
+ struct stmpe *stmpe = data;
+
+ if (!IS_ERR(stmpe->vio) && regulator_is_enabled(stmpe->vio))
+ regulator_disable(stmpe->vio);
+ if (!IS_ERR(stmpe->vcc) && regulator_is_enabled(stmpe->vcc))
+ regulator_disable(stmpe->vcc);
+}
+
int stmpe_probe(struct stmpe_client_info *ci, enum stmpe_partnum partnum)
{
struct stmpe_platform_data *pdata;
@@ -1417,6 +1427,11 @@ int stmpe_probe(struct stmpe_client_info *ci, enum stmpe_partnum partnum)
if (ret)
dev_warn(ci->dev, "failed to enable VIO supply\n");
}
+
+ ret = devm_add_action_or_reset(ci->dev, stmpe_disable_regulators, stmpe);
+ if (ret)
+ return ret;
+
dev_set_drvdata(stmpe->dev, stmpe);

if (ci->init)

---

PoC reproduction (7.4.0-rc2, arm64 QEMU virt, unmodified kernel):

Device tree injection, spliced into the QEMU virt machine DT:

reg_vcc: regulator-0 { compatible = "regulator-fixed";
regulator-name = "stmpe-vcc"; regulator-min-microvolt = <3300000>;
regulator-max-microvolt = <3300000>; };

reg_vio: regulator-1 { compatible = "regulator-fixed";
regulator-name = "stmpe-vio"; regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <1800000>; };

i2c@0 { compatible = "i2c-gpio";
sda-gpios = <&gpio0 0 0>; scl-gpios = <&gpio0 1 0>;
i2c-gpio,delay-us = <2>; #address-cells = <1>; #size-cells = <0>;
stmpe811@41 { compatible = "st,stmpe811"; reg = <0x41>;
vcc-supply = <&reg_vcc>; vio-supply = <&reg_vio>; }; };

The stmpe811 node has no interrupts property, so the probe enables both
rails and then returns -ENODEV on the no-irq check.

Trigger:

modprobe i2c-gpio
modprobe stmpe-i2c

Result:

stmpe-i2c 0-0041: stmpe811 configured in no-irq mode by platform data
stmpe-i2c 0-0041: stmpe811 does not support no-irq mode!
WARNING: drivers/regulator/core.c:2678 at _regulator_put
WARNING: drivers/regulator/core.c:2678 at _regulator_put

Two warnings, one per leaked rail, and the regulator use counts go from
1 to 2 after the failed probe.

Note: the PoC was generated with AI assistance and the vulnerability was
found by static analysis. The device tree is trusted input (a bad DT
requires root or physical access), so this is not a security fix, but it
prevents a potential resource leak or system failure on a failed probe or
an old or malformed DT.