[PATCH] clk: max9485: Disable vdd on probe failure

From: Wang Haoran

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


max9485_i2c_probe() enables the vdd regulator but never disables it: the
driver has no remove callback and no failure-path unwind, so the rail
stays enabled after a failed probe (including -EPROBE_DEFER retries, which
re-enable it each round) and after unbind, and _regulator_put() then warns
on the leaked enable.

Use devm_regulator_get_enable() instead of the manual get and enable, so
the core registers an automatic disable that runs on probe failure and on
removal without adding a new error path.

Signed-off-by: Wang Haoran <wanghr2026@xxxxxxxxxxxxxxxxxx>
Fixes: 33f5104624b9 ("clk: Add driver for MAX9485")
---

diff --git a/drivers/clk/clk-max9485.c b/drivers/clk/clk-max9485.c
index 9c48c0c3a998..68df62ac148c 100644
--- a/drivers/clk/clk-max9485.c
+++ b/drivers/clk/clk-max9485.c
@@ -78,7 +78,6 @@ struct max9485_driver_data {
struct clk *xclk;
struct i2c_client *client;
u8 reg_value;
- struct regulator *supply;
struct gpio_desc *reset_gpio;
struct max9485_clk_hw hw[MAX9485_NUM_CLKS];
};
@@ -278,12 +277,8 @@ static int max9485_i2c_probe(struct i2c_client *client)

xclk_name = __clk_get_name(drvdata->xclk);

- drvdata->supply = devm_regulator_get(dev, "vdd");
- if (IS_ERR(drvdata->supply))
- return PTR_ERR(drvdata->supply);
-
- ret = regulator_enable(drvdata->supply);
- if (ret < 0)
+ ret = devm_regulator_get_enable(dev, "vdd");
+ if (ret)
return ret;

drvdata->reset_gpio =

---

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

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

xclk: clock-0 { compatible = "fixed-clock"; #clock-cells = <0>;
clock-frequency = <12288000>; };

reg_vdd: regulator-0 { compatible = "regulator-fixed";
regulator-name = "max9485-vdd"; 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>;
max9485@63 { compatible = "maxim,max9485"; reg = <0x63>;
clocks = <&xclk>; clock-names = "xclk"; vdd-supply = <&reg_vdd>; }; };

The i2c register read fails on the unanswered bus, so the probe enables vdd
and then returns without disabling it.

Trigger:

modprobe i2c-gpio
modprobe clk-max9485

Result:

max9485 0-0063: Unable to read device register: -6
WARNING: drivers/regulator/core.c:2678 at _regulator_put

The regulator summary shows max9485-vdd with a use count of 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.