On Wed, Jul 09, 2003 at 04:18:25PM -0400, Alan Stern wrote:
> On Wed, 9 Jul 2003, Greg KH wrote:
> 
> > On Mon, Jul 07, 2003 at 10:20:32AM -0400, Alan Stern wrote:
> > > Greg:
> > > 
> > > This fixes a minor error in usb-skeleton's disconnect() routine: if the 
> > > interface's private data is NULL, the current code exits without releasing 
> > > the disconnect_sem semaphore.
> > 
> > Yeah, but if dev is null, then the semaphore is already released, right?
> 
> Wrong.  Here's an extract from the current version of the code:
> 
> static void skel_disconnect(struct usb_interface *interface)
> {
>       struct usb_skel *dev;
>       int minor;
> 
>       /* prevent races with open() */
>       down (&disconnect_sem);
> 
>       dev = usb_get_intfdata (interface);
>       usb_set_intfdata (interface, NULL);
> 
>       if (!dev)
>               return;
> 
> As you can see, disconnect_sem is acquired but not released if dev is 
> NULL.

Ah yes, that is a problem.

> > So yes, the check is being paranoid, but I don't see a problem with
> > being paranoid in this kind of situation, do you?
> 
> Well, I sort of do.  If the pointer really can never be NULL, then it
> doesn't make much difference whether or not you check; the difference is
> code size and speed is completely negligible.  There is a difference in
> clarity though.  Seeing that check makes me wonder, "What's that doing
> there?  How could the pointer ever be NULL?  Is someone just being
> paranoid or can that really happen?"  I don't like that kind of
> distraction when trying to read code.

I am tending to agree with you there.  Ok, I'll go add your patch to my
todo list of things I need to get off my butt and apply (been busy these
past few days, working on a talk, and now am at a conference...)

thanks,

greg k-h


-------------------------------------------------------
This SF.Net email sponsored by: Parasoft
Error proof Web apps, automate testing & more.
Download & eval WebKing and get a free book.
www.parasoft.com/bulletproofapps
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to