phy: hisilicon: fix UTMI reset leaks in INNO USB2 PHY
Subsystems (2)
PATCH 1/1 phy: hisilicon: fix UTMI reset leaks in INNO USB2 PHY
hisi_inno_phy_probe() acquires an exclusive UTMI reset control for each child node but never releases it on probe failure or driver detach. The leaked controls remain acquired, so a later probe can fail with -EBUSY when requesting the same resets.
Register a devres action after each successful lookup to release the control on probe failure and detach.
Found during source review of reset-control lifetimes.
Build-tested the driver object on x86_64 with W=1 and reset support enabled. No hardware testing.
--- drivers/phy/hisilicon/phy-hisi-inno-usb2.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/phy/hisilicon/phy-hisi-inno-usb2.c +9 -0
@@ -132,6 +132,11 @@ static const struct phy_ops hisi_inno_phy_ops = { .owner = THIS_MODULE, }; +static void hisi_inno_phy_reset_put (void *data) +{ +reset_control_put (data); +} +static int hisi_inno_phy_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev;
@@ -169,6 +174,10 @@ static int hisi_inno_phy_probe(struct platform_device *pdev)if (IS_ERR (rst))return PTR_ERR (rst); + ret =devm_add_action_or_reset (dev, hisi_inno_phy_reset_put, rst); +if (ret) +return ret; + priv->ports[i].utmi_rst = rst; priv->ports[i].priv = priv;
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
Quoted 8 lines · Xia Yan
hisi_inno_phy_probe()acquires an exclusive UTMI reset control for each child node but never releases it on probe failure or driver detach. The leaked controls remain acquired, so a later probe can fail with-EBUSYwhen requesting the same resets.Register a devres action after each successful lookup to release the control on probe failure and detach.
Quoted 8 lines
Found during source review of reset-control lifetimes.
Build-tested the driver object on
x86_64with W=1 and reset support enabled. No hardware testing.Fixes ba8b0ee81fbb ("phy: add inno-usb2-phy driver for hi3798cv200 SoC")Cc [email protected] # needs of_node_put(child) on <= 6.6Signed-off-by Xia Yan <[email protected]>
It looks like an equivalent to devm_get_clk_from_child() for reset controls could be useful.
regards
Philipp
Hi Philipp,
Thanks for the review.
Regarding your suggestion about a from_child equivalent, I checked the reset core after your reply. The existing devm reset-control helpers don't provide a way to obtain a reset control from an explicit child device node. I agree that such a helper would be useful.
Do you have a particular API design in mind? If you're not already planning to work on this, I'd be happy to study the reset core and explore a separate follow-up patch. No timeline yet.
For the current fix, I plan to keep the change self-contained in this driver.
Best regards,
Xia Yan
Signature · 3 lines
linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy