]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
USB: phy: am335x-control: fix device and of_node leaks
authorJohan Hovold <johan@kernel.org>
Tue, 1 Nov 2016 10:40:25 +0000 (11:40 +0100)
committerJiri Slaby <jslaby@suse.cz>
Thu, 26 Jan 2017 16:39:47 +0000 (17:39 +0100)
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: Jiri Slaby <jslaby@suse.cz>
drivers/usb/phy/phy-am335x-control.c

index 22cf07d62e4c68f04378b18a70555eb782ba25ff..0b8efff8524c887ebe0a22c20dc1455e5745413f 100644 (file)
@@ -85,7 +85,9 @@ struct phy_control *am335x_get_phy_control(struct device *dev)
                return NULL;
 
        dev = bus_find_device(&platform_bus_type, NULL, node, match);
+       of_node_put(node);
        ctrl_usb = dev_get_drvdata(dev);
+       put_device(dev);
        if (!ctrl_usb)
                return NULL;
        return &ctrl_usb->phy_ctrl;