* [PATCH] clk: max9485: Disable vdd on probe failure
@ 2026-11-19 8:14 Wang Haoran
0 siblings, 0 replies; only message in thread
From: Wang Haoran @ 2026-11-19 8:14 UTC (permalink / raw)
To: sboyd, bmasney+clk, jbrunet+clk; +Cc: linux-clk, linux-kernel, wanghr2026
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@mail.zgclab.edu.cn>
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 = <®_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.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-19 8:14 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-19 8:14 [PATCH] clk: max9485: Disable vdd on probe failure Wang Haoran
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®