ChangeSet 1.1587.3.25, 2004/05/01 16:02:37-07:00, baldrick@free.fr [PATCH] USB: fix WARN_ON in usbfs On Tuesday 27 April 2004 10:58, Oliver Neukum wrote: > Am Dienstag, 27. April 2004 00:14 schrieb Greg KH: > > On Mon, Apr 26, 2004 at 04:05:17PM +0200, Duncan Sands wrote: > > > diff -Nru a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c > > > --- a/drivers/usb/core/devio.c Mon Apr 26 13:48:28 2004 > > > +++ b/drivers/usb/core/devio.c Mon Apr 26 13:48:28 2004 > > > @@ -350,8 +350,8 @@ > > > * all pending I/O requests; 2.6 does that. > > > */ > > > > > > - if (ifnum < 8*sizeof(ps->ifclaimed)) > > > - clear_bit(ifnum, &ps->ifclaimed); > > > + BUG_ON(ifnum >= 8*sizeof(ps->ifclaimed)); > > > > I've changed that to a WARN_ON(). Yeah, writing over memory is bad, but > > oopsing is worse. Let's be a bit nicer than that. > > You aren't nice that way. An oops has localised consequences. Scribbling > over memory can cause anything. Hi Greg, if won't accept a BUG_ON, how about the following? drivers/usb/core/devio.c | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-) diff -Nru a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c --- a/drivers/usb/core/devio.c Fri May 14 15:30:44 2004 +++ b/drivers/usb/core/devio.c Fri May 14 15:30:44 2004 @@ -325,8 +325,11 @@ * all pending I/O requests; 2.6 does that. */ - WARN_ON(ifnum >= 8*sizeof(ps->ifclaimed)); - clear_bit(ifnum, &ps->ifclaimed); + if (likely(ifnum < 8*sizeof(ps->ifclaimed))) + clear_bit(ifnum, &ps->ifclaimed); + else + warn("interface number %u out of range", ifnum); + usb_set_intfdata (intf, NULL); /* force async requests to complete */