[PATCH] regulator: tps6594-regulator: avoid refcount drain on probe

From: Wang Haoran

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


tps6594_regulator_probe() passes tps->dev->of_node to
of_find_node_by_name(), which unconditionally drops the from-node
reference the caller never held. Each multi-phase loop iteration drains the
PMIC node refcount by one (four puts on a tps6594-q1 multi-phase group).
Once it hits zero, of_node_release() deadlocks in its error printk (%pOF on
the parent while holding devtree_lock with IRQs off), so the machine hangs
silently with no oops and no log.

Hold a reference before the call.

Signed-off-by: Wang Haoran <wanghr2026@xxxxxxxxxxxxxxxxxx>
Fixes: f17ccc5deb4d ("regulator: tps6594-regulator: Add driver for TI TPS6594 regulators")
---

diff --git a/drivers/regulator/tps6594-regulator.c b/drivers/regulator/tps6594-regulator.c
index fbf365a46a9e..949441a52482 100644
--- a/drivers/regulator/tps6594-regulator.c
+++ b/drivers/regulator/tps6594-regulator.c
@@ -672,7 +672,8 @@ static int tps6594_regulator_probe(struct platform_device *pdev)
struct device_node *np_parent;

multi_regs = &desc->multi_phase_regs[multi];
- np = of_find_node_by_name(tps->dev->of_node, multi_regs->supply_name);
+ np = of_find_node_by_name(of_node_get(tps->dev->of_node),
+ multi_regs->supply_name);
if (!np)
continue;


---

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

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

spi@0 { compatible = "spi-gpio";
sck-gpios = <&gpio0 4 0>; mosi-gpios = <&gpio0 5 0>;
miso-gpios = <&gpio0 6 0>; cs-gpios = <&gpio0 7 0>;
num-chipselects = <1>; #address-cells = <1>; #size-cells = <0>;
pmic@0 { compatible = "ti,tps6594-q1"; reg = <0>;
spi-max-frequency = <100000>;
interrupt-parent = <&gpio0>; interrupts = <0 2>; }; };

The multi-phase regulator group makes the probe run the of_find_node_by_name()
call once per phase on the PMIC node.

Trigger:

modprobe tps6594-regulator
modprobe spi-gpio
modprobe tps6594-spi

Result:

SPI driver tps6594 has no spi_device_id for ti,tps6594-q1
(no further output)

The regulator probe then hangs the machine silently inside of_node_release()
when the PMIC node refcount reaches zero.

Control: with the same DT and tps6594-regulator.ko removed the system boots
and powers off cleanly.

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.