Re: [PATCH] USB: phy: am335x-control: fix device and of_node leaks
On Thu, Nov 03, 2016 at 10:54:33AM +0200, Felipe Balbi wrote: > > Hi, > > Johan Hovoldwrites: > > 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") > > Signed-off-by: Johan Hovold > > --- > > drivers/usb/phy/phy-am335x-control.c | 2 ++ > > 1 file changed, 2 insertions(+) > > > > 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) > > return NULL; > > > > dev = bus_find_device(_bus_type, NULL, node, match); > > + of_node_put(node); > > if (!dev) > > return NULL; > > > > ctrl_usb = dev_get_drvdata(dev); > > + put_device(dev); > > if (!ctrl_usb) > > return NULL; > > return _usb->phy_ctrl; > > Bin, Roger, does this look okay to you? Looks good to me. Thanks for catching this. Acked-by: Bin Liu Regards, -Bin. -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] USB: phy: am335x-control: fix device and of_node leaks
Hi, Johan Hovoldwrites: > 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") > Signed-off-by: Johan Hovold > --- > drivers/usb/phy/phy-am335x-control.c | 2 ++ > 1 file changed, 2 insertions(+) > > 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) > return NULL; > > dev = bus_find_device(_bus_type, NULL, node, match); > + of_node_put(node); > if (!dev) > return NULL; > > ctrl_usb = dev_get_drvdata(dev); > + put_device(dev); > if (!ctrl_usb) > return NULL; > return _usb->phy_ctrl; Bin, Roger, does this look okay to you? -- balbi signature.asc Description: PGP signature
[PATCH] USB: phy: am335x-control: fix device and of_node leaks
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") Signed-off-by: Johan Hovold--- drivers/usb/phy/phy-am335x-control.c | 2 ++ 1 file changed, 2 insertions(+) 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) return NULL; dev = bus_find_device(_bus_type, NULL, node, match); + of_node_put(node); if (!dev) return NULL; ctrl_usb = dev_get_drvdata(dev); + put_device(dev); if (!ctrl_usb) return NULL; return _usb->phy_ctrl; -- 2.7.3 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html