[PATCH] input: hideep: Roll back regulators on power on failure

From: Wang Haoran

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


hideep_power_on() enables the vdd and vid regulators but does not roll
them back when a later step fails. When the reset command write fails, the
probe returns before the devm action is registered, so both rails stay
enabled; a subsequent probe retry then enables them again, and the leaked
enables make _regulator_put() warn. The enable failures themselves are also
only logged and neither propagated nor rolled back.

Disable the already enabled rail(s) on failure, return the enable errors
right away, and disable both rails when the reset write fails.

Signed-off-by: Wang Haoran <wanghr2026@xxxxxxxxxxxxxxxxxx>
Fixes: 842ff286166e ("Input: add support for HiDeep touchscreen")
---

diff --git a/drivers/input/touchscreen/hideep.c b/drivers/input/touchscreen/hideep.c
index 9384657ece7e..ecd730763821 100644
--- a/drivers/input/touchscreen/hideep.c
+++ b/drivers/input/touchscreen/hideep.c
@@ -661,17 +661,22 @@ static int hideep_power_on(struct hideep_ts *ts)
int error = 0;

error = regulator_enable(ts->vcc_vdd);
- if (error)
+ if (error) {
dev_err(&ts->client->dev,
"failed to enable 'vdd' regulator: %d", error);
+ return error;
+ }

usleep_range(999, 1000);

error = regulator_enable(ts->vcc_vid);
- if (error)
+ if (error) {
dev_err(&ts->client->dev,
"failed to enable 'vcc_vid' regulator: %d",
error);
+ regulator_disable(ts->vcc_vdd);
+ return error;
+ }

msleep(30);

@@ -679,9 +684,12 @@ static int hideep_power_on(struct hideep_ts *ts)
gpiod_set_value_cansleep(ts->reset_gpio, 0);
} else {
error = regmap_write(ts->reg, HIDEEP_RESET_CMD, 0x01);
- if (error)
+ if (error) {
dev_err(&ts->client->dev,
"failed to send 'reset' command: %d\n", error);
+ regulator_disable(ts->vcc_vid);
+ regulator_disable(ts->vcc_vdd);
+ }
}

msleep(50);

---

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

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

reg_vdd: regulator-0 { compatible = "regulator-fixed";
regulator-name = "hideep-vdd"; regulator-min-microvolt = <3300000>;
regulator-max-microvolt = <3300000>; };

reg_vid: regulator-1 { compatible = "regulator-fixed";
regulator-name = "hideep-vid"; regulator-min-microvolt = <3300000>;
regulator-max-microvolt = <3300000>; };

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>;
hideep@41 { compatible = "hideep,hideep-ts"; reg = <0x41>;
interrupt-parent = <&gpio0>; interrupts = <2 8>;
vdd-supply = <&reg_vdd>; vid-supply = <&reg_vid>; }; };

The device has no reset gpio, so the reset command write fails on the
unanswered bus after both rails have been enabled.

Trigger:

modprobe i2c-gpio
modprobe hideep

Result:

hideep_ts 0-0041: failed to send 'reset' command: -6
hideep_ts 0-0041: power on failed: -6
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.