On Wed, Feb 19, 2003, Greg KH <[EMAIL PROTECTED]> wrote:
> On Wed, Feb 19, 2003 at 07:33:57PM -0500, Johannes Erdfelt wrote:
> > > But what about drivers that fire off urbs and don't keep a pointer to
> > > them around?  They don't know if all of their urbs are completed or not,
> > > nor should they really care.  The visor driver is one good example of
> > > this.
> > 
> > Sounds broken to me. Someone needs to keep track of it, and it's not the
> > core right now.
> > 
> > I think they should care simply because they allocated the memory and
> > submitted the URB.
> > 
> > It's very irresponsible to expect someone else to deal with your mess :)
> 
> Heh.  No, urbs are referenced counted now.  So a driver can do the
> following just fine:
>       - usb_alloc_urb()
>       - urb data = kmalloc()
>       - usb_submit_urb()
>       - usb_free_urb()
> 
> Then later in the completion function you free the transfer buffer.
> When the hcd is done with the urb, the last urb_free_urb() call in the
> hcd causes the urb to disappear.
> 
> No worries or overhead in the usb driver to keep track of all of
> the urbs it created, enabling very simple code.
> 
> So I guess I do need to add module reference counting to urbs in order
> to get this case to work properly.  I'll look into it...

It seems to me that this is dangerous.

The only way this could work is if some other code (core, HCD) keeps
track of the URBs and then unlinks them when disconnect processing
happens.

Otherwise, the device could be closed by the application and the driver
unloaded only to have URBs it allocated still active only to have a
callback made into an old modules address space.

JE



-------------------------------------------------------
This SF.net email is sponsored by: SlickEdit Inc. Develop an edge.
The most comprehensive and flexible code editor you can use.
Code faster. C/C++, C#, Java, HTML, XML, many more. FREE 30-Day Trial.
www.slickedit.com/sourceforge
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to