mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2024-12-28 00:33:16 +00:00
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: b7563e2796
("phy: work around 'phys' references to usb-nop-xceiv devices")
Cc: stable@vger.kernel.org
Reviewed-by: Johan Hovold <johan+linaro@kernel.org>
Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
Link: https://lore.kernel.org/r/20241213-phy_core_fix-v6-4-40ae28f5015a@quicinc.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
This commit is contained in:
parent
4dc48c88fc
commit
5ebdc6be16
@ -629,8 +629,10 @@ static struct phy *_of_phy_get(struct device_node *np, int index)
|
||||
return ERR_PTR(-ENODEV);
|
||||
|
||||
/* This phy type handled by the usb-phy subsystem for now */
|
||||
if (of_device_is_compatible(args.np, "usb-nop-xceiv"))
|
||||
return ERR_PTR(-ENODEV);
|
||||
if (of_device_is_compatible(args.np, "usb-nop-xceiv")) {
|
||||
phy = ERR_PTR(-ENODEV);
|
||||
goto out_put_node;
|
||||
}
|
||||
|
||||
mutex_lock(&phy_provider_mutex);
|
||||
phy_provider = of_phy_provider_lookup(args.np);
|
||||
@ -652,6 +654,7 @@ static struct phy *_of_phy_get(struct device_node *np, int index)
|
||||
|
||||
out_unlock:
|
||||
mutex_unlock(&phy_provider_mutex);
|
||||
out_put_node:
|
||||
of_node_put(args.np);
|
||||
|
||||
return phy;
|
||||
|
Loading…
Reference in New Issue
Block a user