Skip to content

Commit 5ebdc6b

Browse files
Zijun Huvinodkoul
authored andcommitted
phy: core: Fix an OF node refcount leakage in _of_phy_get()
_of_phy_get() will directly return when suffers of_device_is_compatible() error, but it forgets to decrease refcount of OF node @args.np before error return, the refcount was increased by previous of_parse_phandle_with_args() so causes the OF node's refcount leakage. Fix by decreasing the refcount via of_node_put() before the error return. Fixes: b7563e2 ("phy: work around 'phys' references to usb-nop-xceiv devices") Cc: [email protected] Reviewed-by: Johan Hovold <[email protected]> Signed-off-by: Zijun Hu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent 4dc48c8 commit 5ebdc6b

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

drivers/phy/phy-core.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -629,8 +629,10 @@ static struct phy *_of_phy_get(struct device_node *np, int index)
629629
return ERR_PTR(-ENODEV);
630630

631631
/* This phy type handled by the usb-phy subsystem for now */
632-
if (of_device_is_compatible(args.np, "usb-nop-xceiv"))
633-
return ERR_PTR(-ENODEV);
632+
if (of_device_is_compatible(args.np, "usb-nop-xceiv")) {
633+
phy = ERR_PTR(-ENODEV);
634+
goto out_put_node;
635+
}
634636

635637
mutex_lock(&phy_provider_mutex);
636638
phy_provider = of_phy_provider_lookup(args.np);
@@ -652,6 +654,7 @@ static struct phy *_of_phy_get(struct device_node *np, int index)
652654

653655
out_unlock:
654656
mutex_unlock(&phy_provider_mutex);
657+
out_put_node:
655658
of_node_put(args.np);
656659

657660
return phy;

0 commit comments

Comments
 (0)