I have the strong feeling that the "Subject: " line for this
series of posts should change:
Aunt Tillie Writes a USB Device Driver :)
Specifically which drivers do you think have this problem?
I think I see variants of it in ov511, pwc, and se401. That's
just looking at some of the few drivers that do their own
module refcounts; network and char devices shouldn't do
that, but they could have analagous bugs.
The basic issue seems to be something we've known for
a while: not all drivers handle disconnect() correctly. They
need to get rid of all pending requests, with no exceptions
made for requests (or completions, which seems to be the
issue you're highlighting here) that are "in flight". If they do
that correctly, then when the module_exit() code returns
it'll always be safe to unload.
I recall thinking about related issues with "usbnet". There,
the disconnect() processing uses async unlinks, and blocks
until it's explicitly woken up by the completion code after all
the pending urbs are unlinked and freed.
No "wait_for_completion_handler()" API is needed, since
the <linux/completion.h> and the a correct completion handler
will do the job quite naturally.
- Dave
p.s. Surely you mean usb_free_urb(u), not kfree(u) ...
----- Original Message -----
From: "Oliver Neukum" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, January 19, 2002 1:46 PM
Subject: [linux-usb-devel] race between usb_unlink_urb and module unload
> Hi,
>
> there's another race I failed to see.
>
> This shortened version of quite common code is racy:
>
> usb_unlink_urb(u);
> kfree(u);
> MOD_DEC_USE_COUNT;
>
> It would have to be:
> usb_unlink_urb();
> usb_wait_for_completion_handler(); //to be written
> kfree(u);
> MOD_DEC_USE_COUNT;
>
> The problem is that the completion handler itself can't provide
> that hypothetical function, because itself might be unloaded.
>
> Regards
> Oliver
>
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel