Re: [PATCH] USB: phy: am335x-control: fix device and of_node leaks

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Nov 03, 2016 at 10:54:33AM +0200, Felipe Balbi wrote:
> 
> Hi,
> 
> Johan Hovold <johan@xxxxxxxxxx> writes:
> > 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 <johan@xxxxxxxxxx>
> > ---
> >  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(&platform_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 &ctrl_usb->phy_ctrl;
> 
> Bin, Roger, does this look okay to you?

Looks good to me. Thanks for catching this.

Acked-by: Bin Liu <b-liu@xxxxxx>

Regards,
-Bin.
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux