[PATCH] media: i2c: dw9719: disable vdd on detection failure
From: Wang Haoran
Date: Thu Nov 19 2026 - 03:15:24 EST
dw9719_power_up() enables the vdd regulator but neither the INFO register
read error nor the unknown device id path disables it again, and the probe
error path does not call dw9719_power_down(). Device detection is the
driver's normal hot-plug path, so a missing or mismatched module leaves the
VCM rail enabled after every failed probe and _regulator_put() warns on the
leaked enable.
Disable the regulator on these detection failures.
Signed-off-by: Wang Haoran <wanghr2026@xxxxxxxxxxxxxxxxxx>
Fixes: fed60fc552c8 ("media: i2c: Add driver for DW9719 VCM")
---
diff --git a/drivers/media/i2c/dw9719.c b/drivers/media/i2c/dw9719.c
index 5d5da0439dba..d1aef321e26c 100644
--- a/drivers/media/i2c/dw9719.c
+++ b/drivers/media/i2c/dw9719.c
@@ -149,8 +149,10 @@ static int dw9719_power_up(struct dw9719_device *dw9719, bool detect)
}
ret = cci_read(dw9719->regmap, DW9719_INFO, &val, NULL);
- if (ret < 0)
+ if (ret < 0) {
+ dw9719_power_down(dw9719);
return ret;
+ }
switch (val) {
case DW9719_ID:
@@ -168,6 +170,7 @@ static int dw9719_power_up(struct dw9719_device *dw9719, bool detect)
default:
dev_err(dw9719->dev,
"Error unknown device id 0x%02llx\n", val);
+ dw9719_power_down(dw9719);
return -ENXIO;
}
---
PoC reproduction (7.4.0-rc2, arm64 QEMU virt, unmodified kernel):
Route 1 (i2c-stub, no DT injection needed):
modprobe i2c-stub chip_addr=0x2c
echo "dw9719 0x40" > /sys/bus/i2c/devices/i2c-0/new_device
The probe powers up the device and the INFO register read fails on the
unanswered address.
Result:
i2c i2c-0: new_device: Instantiated device dw9719 at 0x40
dw9719 0-0040: Error reading reg 0x0000: -19
WARNING: drivers/regulator/core.c:2678 at _regulator_put
The regulator-dummy use count rises by one on every failed probe (and on
every delete/new_device retry) and never drops.
Note: the PoC was generated with AI assistance and the vulnerability was
found by static analysis. Triggering the failed probe via sysfs requires
root, so this is not a security fix, but it prevents a potential resource
leak on a failed probe.