On Wed, Sep 24, 2003 at 06:04:38PM -0700, David Brownell wrote:
/* Decrement the reference count, it'll auto free everything when */ /* it hits 0 which could very well be now */ + /* FIXME the decrement in device_unregister() should suffice ... */ usb_put_dev(dev);
Not true at all. We need that last put_dev, as we called usb_get_dev in the top of usb_new_device().
Then the fix should then be to remove both of those, yes? The comment doesn't imply that's the only thing to change... :)
Try it :) From what I recall, we have to increment the count at this point, as we increment it and decrement it when we start talking to the device (getting the config and stuff.) This is because when we submit a urb, we increment the device's count.
I didn't want to make the time to test those changes too ... ;)
That refcount bug (now fixed) in usb_new_device() error paths could have benefited (oopses vanishing) from having an extra refcount. I could believe those problems were covering up for each other; they were right in the same area, and neither made sense otherwise.
The only reason I can see to have an extra refcount in that path is in case the counted pointer (hub->children[]) gets freed somehow while there's still another copy of that pointer, used on the stack. Otherwise the normal "shared lifetime" rules apply ... and even in that case, the extra refcount should be dropped when the copy from the stack goes away.
When a GET_DESCRIPTOR (or SET_ADDRESS, or SET_CONFIGURATION, etc) request gets made, there's a temporary extra refcount that's only maintained during the invocation path. It's transparent, and it goes back (for example, down to one) when the call returns. From the perspective of the synchronous usb_new_device() logic, it won't matter: that code already has a valid refcount.
- Dave
It was because of this we added device_add() and device_initialize() to the driver core to handle the two stage initialization.
thanks,
greg k-h
------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ [EMAIL PROTECTED] To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
