From: Duncan Sands <baldrick@free.fr>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Greg KH <greg@kroah.com>, <linux-usb-devel@lists.sf.net>,
<linux-kernel@vger.kernel.org>, Frederic Detienne <fd@cisco.com>,
David Brownell <david-b@pacbell.net>
Subject: Re: [linux-usb-devel] [PATCH 7/9] USB usbfs: destroy submitted urbs only on the disconnected interface
Date: Wed, 14 Apr 2004 19:09:29 +0200 [thread overview]
Message-ID: <200404141909.29810.baldrick@free.fr> (raw)
In-Reply-To: <Pine.LNX.4.44L0.0404141226370.1474-100000@ida.rowland.org>
> On Wed, 14 Apr 2004, Duncan Sands wrote:
> > diff -Nru a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
> > --- a/drivers/usb/core/devio.c Wed Apr 14 12:18:20 2004
> > +++ b/drivers/usb/core/devio.c Wed Apr 14 12:18:20 2004
> > @@ -341,6 +341,7 @@
> > static void driver_disconnect(struct usb_interface *intf)
> > {
> > struct dev_state *ps = usb_get_intfdata (intf);
> > + unsigned int ifnum = intf->altsetting->desc.bInterfaceNumber;
> >
> > if (!ps)
> > return;
> > @@ -349,11 +350,12 @@
> > * all pending I/O requests; 2.6 does that.
> > */
> >
> > - clear_bit(intf->cur_altsetting->desc.bInterfaceNumber, &ps->ifclaimed);
> > + if (ifnum < 8*sizeof(ps->ifclaimed))
> > + clear_bit(ifnum, &ps->ifclaimed);
> > usb_set_intfdata (intf, NULL);
> >
> > /* force async requests to complete */
> > - destroy_all_async (ps);
> > + destroy_async_on_interface(ps, ifnum);
> > }
> >
> > struct usb_driver usbdevfs_driver = {
>
> Quite apart from the stylistic questions about sanity tests and so on,
> this code contains a bug. It wasn't introduced by your patch; it was
> there from before and I should have caught it earlier, along with a few
> others.
Hi Alan, it was introduced after your last devio.c fixes by the patch
"fix xsane breakage, hangs on device scan at launch" by someone
who will remain nameless :)
> The real problem is that the code in devio.c doesn't make a clear visual
> distinction between interface number (i.e., desc.bInterfaceNumber) and
> interface index (i.e., dev->actconfig->interface[index]). The two values
> do not have to agree.
>
> The claimintf(), releaseintf(), and checkintf() routines take an index as
> argument, and the ifclaimed bitvector uses the same index. findintfif()
> takes a number and returns the corresponding index, duplicating much of
> the functionality of usb_ifnum_to_if(). Likewise, findintfep() returns an
> index.
>
> The code here in driver_disconnect() uses a number where it needs to use
> an index.
>
> Similarly, there's a typo in proc_releaseinterface(); the second argument
> it passes to releaseintf() should be ret, not intf.
>
> And in proc_submiturb(), the value stored in as->intf is an index when it
> should be an interface number. Or possibly it could remain an index, but
> then the value passed to destroy_async_on_interface() by
> proc_releaseinterface() should be the index and not the number.
Good catch! I guess the index and the interface differ because interfaces are
not always consecutively numbered. Is that right? When can it happen?
Thanks,
Duncan.
next prev parent reply other threads:[~2004-04-14 17:09 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-04-14 10:45 [PATCH 7/9] USB usbfs: destroy submitted urbs only on the disconnected interface Duncan Sands
2004-04-14 13:30 ` [linux-usb-devel] " Oliver Neukum
2004-04-14 13:38 ` Duncan Sands
2004-04-14 15:00 ` Duncan Sands
2004-04-14 15:33 ` Oliver Neukum
2004-04-14 15:39 ` Duncan Sands
2004-04-14 20:39 ` Oliver Neukum
2004-04-15 8:05 ` Duncan Sands
2004-04-15 8:31 ` Oliver Neukum
2004-04-15 8:47 ` Duncan Sands
2004-04-15 9:08 ` Oliver Neukum
2004-04-15 9:21 ` Duncan Sands
2004-04-14 16:48 ` Alan Stern
2004-04-14 17:09 ` Duncan Sands [this message]
2004-04-14 17:55 ` Alan Stern
2004-04-17 18:31 ` Duncan Sands
2004-04-17 18:53 ` Duncan Sands
2004-04-17 19:52 ` Alan Stern
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200404141909.29810.baldrick@free.fr \
--to=baldrick@free.fr \
--cc=david-b@pacbell.net \
--cc=fd@cisco.com \
--cc=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb-devel@lists.sf.net \
--cc=stern@rowland.harvard.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox