Skip to content

Commit d6ef1c6

Browse files
jhovoldgregkh
authored andcommitted
phy: ti: omap-usb2: fix device leak at unbind
[ Upstream commit 6496155 ] 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: 478b6c7 ("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: Sasha Levin <sashal@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent aea48dc commit d6ef1c6

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

drivers/phy/ti/phy-omap-usb2.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,13 @@ static void omap_usb2_init_errata(struct omap_usb *phy)
363363
phy->flags |= OMAP_USB2_DISABLE_CHRG_DET;
364364
}
365365

366+
static void omap_usb2_put_device(void *_dev)
367+
{
368+
struct device *dev = _dev;
369+
370+
put_device(dev);
371+
}
372+
366373
static int omap_usb2_probe(struct platform_device *pdev)
367374
{
368375
struct omap_usb *phy;
@@ -373,6 +380,7 @@ static int omap_usb2_probe(struct platform_device *pdev)
373380
struct device_node *control_node;
374381
struct platform_device *control_pdev;
375382
const struct usb_phy_data *phy_data;
383+
int ret;
376384

377385
phy_data = device_get_match_data(&pdev->dev);
378386
if (!phy_data)
@@ -423,6 +431,11 @@ static int omap_usb2_probe(struct platform_device *pdev)
423431
return -EINVAL;
424432
}
425433
phy->control_dev = &control_pdev->dev;
434+
435+
ret = devm_add_action_or_reset(&pdev->dev, omap_usb2_put_device,
436+
phy->control_dev);
437+
if (ret)
438+
return ret;
426439
} else {
427440
if (of_property_read_u32_index(node,
428441
"syscon-phy-power", 1,

0 commit comments

Comments
 (0)