diff options
| author | Johan Hovold <johan@kernel.org> | 2016-11-01 06:40:25 -0400 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-01-12 05:39:20 -0500 |
| commit | 93f6891a383f92f88793da1e46cb018bdef8c18a (patch) | |
| tree | e7da4acf98fd337d7e12930f2ef1818f0a010ea2 /drivers/usb/phy | |
| parent | d387f98cb0c1e70ad45daacfb96acec4a5e0cb60 (diff) | |
USB: phy: am335x-control: fix device and of_node leaks
commit 015105b12183556771e111e93f5266851e7c5582 upstream.
Make sure to drop the references taken by of_parse_phandle() and
bus_find_device() before returning from am335x_get_phy_control().
Note that there is no guarantee that the devres-managed struct
phy_control will be valid for the lifetime of the sibling phy device
regardless of this change.
Fixes: 3bb869c8b3f1 ("usb: phy: Add AM335x PHY driver")
Acked-by: Bin Liu <b-liu@ti.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/phy')
| -rw-r--r-- | drivers/usb/phy/phy-am335x-control.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/usb/phy/phy-am335x-control.c b/drivers/usb/phy/phy-am335x-control.c index 42a1afe36a90..5f5f19813fde 100644 --- a/drivers/usb/phy/phy-am335x-control.c +++ b/drivers/usb/phy/phy-am335x-control.c | |||
| @@ -134,10 +134,12 @@ struct phy_control *am335x_get_phy_control(struct device *dev) | |||
| 134 | return NULL; | 134 | return NULL; |
| 135 | 135 | ||
| 136 | dev = bus_find_device(&platform_bus_type, NULL, node, match); | 136 | dev = bus_find_device(&platform_bus_type, NULL, node, match); |
| 137 | of_node_put(node); | ||
| 137 | if (!dev) | 138 | if (!dev) |
| 138 | return NULL; | 139 | return NULL; |
| 139 | 140 | ||
| 140 | ctrl_usb = dev_get_drvdata(dev); | 141 | ctrl_usb = dev_get_drvdata(dev); |
| 142 | put_device(dev); | ||
| 141 | if (!ctrl_usb) | 143 | if (!ctrl_usb) |
| 142 | return NULL; | 144 | return NULL; |
| 143 | return &ctrl_usb->phy_ctrl; | 145 | return &ctrl_usb->phy_ctrl; |
