phy: ti: omap-usb2: fix device leak at unbind

commit 64961557ef upstream.

Make sure to drop the reference to the control device taken by
of_find_device_by_node() during probe when the driver is unbound.

Fixes: 478b6c7436 ("usb: phy: omap-usb2: Don't use omap_get_control_dev()")
Cc: stable@vger.kernel.org	# 3.13
Cc: Roger Quadros <rogerq@kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
Link: https://lore.kernel.org/r/20250724131206.2211-3-johan@kernel.org
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Johan Hovold 2025-07-24 15:12:05 +02:00 committed by Greg Kroah-Hartman
parent 28cfc6ab15
commit 4dae01a7b2
1 changed files with 13 additions and 0 deletions

View File

@ -363,6 +363,13 @@ static void omap_usb2_init_errata(struct omap_usb *phy)
phy->flags |= OMAP_USB2_DISABLE_CHRG_DET; phy->flags |= OMAP_USB2_DISABLE_CHRG_DET;
} }
static void omap_usb2_put_device(void *_dev)
{
struct device *dev = _dev;
put_device(dev);
}
static int omap_usb2_probe(struct platform_device *pdev) static int omap_usb2_probe(struct platform_device *pdev)
{ {
struct omap_usb *phy; struct omap_usb *phy;
@ -373,6 +380,7 @@ static int omap_usb2_probe(struct platform_device *pdev)
struct device_node *control_node; struct device_node *control_node;
struct platform_device *control_pdev; struct platform_device *control_pdev;
const struct usb_phy_data *phy_data; const struct usb_phy_data *phy_data;
int ret;
phy_data = device_get_match_data(&pdev->dev); phy_data = device_get_match_data(&pdev->dev);
if (!phy_data) if (!phy_data)
@ -423,6 +431,11 @@ static int omap_usb2_probe(struct platform_device *pdev)
return -EINVAL; return -EINVAL;
} }
phy->control_dev = &control_pdev->dev; phy->control_dev = &control_pdev->dev;
ret = devm_add_action_or_reset(&pdev->dev, omap_usb2_put_device,
phy->control_dev);
if (ret)
return ret;
} else { } else {
if (of_property_read_u32_index(node, if (of_property_read_u32_index(node,
"syscon-phy-power", 1, "syscon-phy-power", 1,