Commit 93f6891a authored by Johan Hovold's avatar Johan Hovold Committed by Greg Kroah-Hartman

USB: phy: am335x-control: fix device and of_node leaks

commit 015105b1 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: 3bb869c8 ("usb: phy: Add AM335x PHY driver")
Acked-by: default avatarBin Liu <b-liu@ti.com>
Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent d387f98c
...@@ -134,10 +134,12 @@ struct phy_control *am335x_get_phy_control(struct device *dev) ...@@ -134,10 +134,12 @@ struct phy_control *am335x_get_phy_control(struct device *dev)
return NULL; return NULL;
dev = bus_find_device(&platform_bus_type, NULL, node, match); dev = bus_find_device(&platform_bus_type, NULL, node, match);
of_node_put(node);
if (!dev) if (!dev)
return NULL; return NULL;
ctrl_usb = dev_get_drvdata(dev); ctrl_usb = dev_get_drvdata(dev);
put_device(dev);
if (!ctrl_usb) if (!ctrl_usb)
return NULL; return NULL;
return &ctrl_usb->phy_ctrl; return &ctrl_usb->phy_ctrl;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment