Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 170eaf9

Browse files
jhovoldgregkh
authored andcommitted
phy: ti-pipe3: fix device leak at unbind
commit e19bcea 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: 918ee0d ("usb: phy: omap-usb3: Don't use omap_get_control_dev()") Cc: [email protected] # 3.13 Cc: Roger Quadros <[email protected]> Signed-off-by: Johan Hovold <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 4dae01a commit 170eaf9

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

drivers/phy/ti/phy-ti-pipe3.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,12 +667,20 @@ static int ti_pipe3_get_clk(struct ti_pipe3 *phy)
667667
return 0;
668668
}
669669

670+
static void ti_pipe3_put_device(void *_dev)
671+
{
672+
struct device *dev = _dev;
673+
674+
put_device(dev);
675+
}
676+
670677
static int ti_pipe3_get_sysctrl(struct ti_pipe3 *phy)
671678
{
672679
struct device *dev = phy->dev;
673680
struct device_node *node = dev->of_node;
674681
struct device_node *control_node;
675682
struct platform_device *control_pdev;
683+
int ret;
676684

677685
phy->phy_power_syscon = syscon_regmap_lookup_by_phandle(node,
678686
"syscon-phy-power");
@@ -704,6 +712,11 @@ static int ti_pipe3_get_sysctrl(struct ti_pipe3 *phy)
704712
}
705713

706714
phy->control_dev = &control_pdev->dev;
715+
716+
ret = devm_add_action_or_reset(dev, ti_pipe3_put_device,
717+
phy->control_dev);
718+
if (ret)
719+
return ret;
707720
}
708721

709722
if (phy->mode == PIPE3_MODE_PCIE) {

0 commit comments

Comments
 (0)