Messages in this thread | | | Date | Mon, 21 Sep 2020 21:08:12 -0400 | From | Alan Stern <> | Subject | Re: [PATCH v2 2/2] USB: misc: Add onboard_usb_hub driver |
| |
On Mon, Sep 21, 2020 at 05:41:58PM -0700, Matthias Kaehlcke wrote: > > > + put_device(hub->dev); > > > > Is there a matching get_device somewhere (like in _find_onboard_hub)? > > If so, I didn't see it. And I don't see any reason for it. > > Yes, implicitly, of_find_device_by_node() "takes a reference to the > embedded struct device which needs to be dropped after use."
Okay. In that case it probably would be better to do the put_device() right away, at the end of _find_onboard_hub().
There would be no danger of the platform device getting freed too soon if you make onboard_hub_remove unbind the associated USB hub devices. But there would still be a danger of those devices somehow getting rebound again at the wrong time; this suggests that you should add a flag to the onboard_hub structure saying that the platform device is about to go away.
Alan Stern
| |