Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1280363
| From | Dmitry Torokhov <dmitry.torokhov@gmail.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH] usb: interface: allow drivers declare number of endpoints they need |
| Date | 2015-11-30 23:30 +0100 |
| Message-ID | <qAF7k-15b-3@gated-at.bofh.it> (permalink) |
| References | <qAE1z-r5-1@gated-at.bofh.it> <qAEuC-Cc-5@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Mon, Nov 30, 2015 at 03:39:43PM -0600, Felipe Balbi wrote:
>
> Hi,
>
> Dmitry Torokhov <dmitry.torokhov@gmail.com> writes:
> > USB interface drivers need to check number of endpoints before trying to
> > access/use them. Quite a few drivers only use the default setting
> > (altsetting 0), so let's allow them to declare number of endpoints in
> > altsetting 0 they require to operate and have USB core check it for us
> > instead of having every driver implement check manually.
> >
> > For compatibility, if driver does not specify number of endpoints (i.e.
> > number of endpoints is left at 0) we bypass the check in USB core and
> > expect the driver perform necessary checks on its own.
> >
> > Acked-by: Alan Stern <stern@rowland.harvard.edu>
> > Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> > ---
> >
> > Greg, if the patch is reasonable I wonder if I can take it through my
> > tree, as I have a few drivers that do not check number of endpoints
> > properly and will crash the kernel when specially crafted device is
> > plugged in, as reported by Vladis Dronov.
> >
> > drivers/usb/core/driver.c | 9 +++++++++
> > include/linux/usb.h | 7 +++++++
> > 2 files changed, 16 insertions(+)
> >
> > diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
> > index 6b5063e..d9f680d 100644
> > --- a/drivers/usb/core/driver.c
> > +++ b/drivers/usb/core/driver.c
> > @@ -306,6 +306,15 @@ static int usb_probe_interface(struct device *dev)
> >
> > dev_dbg(dev, "%s - got id\n", __func__);
> >
> > + if (driver->num_endpoints &&
>
> this part of the check is pointless, right ?
>
> > + intf->altsetting[0].desc.bNumEndpoints < driver->num_endpoints) {
>
> bNumEndpoints will never be less than 0 and if it is, we're gonna have
> issues elsewhere anyway.
Fair enough, I'll drop it.
Thanks.
--
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH] usb: interface: allow drivers declare number of endpoints they need Dmitry Torokhov <dmitry.torokhov@gmail.com> - 2015-11-30 22:20 +0100
Re: [PATCH] usb: interface: allow drivers declare number of endpoints they need Felipe Balbi <balbi@ti.com> - 2015-11-30 22:50 +0100
Re: [PATCH] usb: interface: allow drivers declare number of endpoints they need Dmitry Torokhov <dmitry.torokhov@gmail.com> - 2015-11-30 23:30 +0100
Re: [PATCH] usb: interface: allow drivers declare number of endpoints they need Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2015-11-30 23:20 +0100
Re: [PATCH] usb: interface: allow drivers declare number of endpoints they need Dmitry Torokhov <dmitry.torokhov@gmail.com> - 2015-12-01 00:00 +0100
Re: [PATCH] usb: interface: allow drivers declare number of endpoints they need Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2015-12-01 00:40 +0100
Re: [PATCH] usb: interface: allow drivers declare number of endpoints they need Dmitry Torokhov <dmitry.torokhov@gmail.com> - 2015-12-01 01:50 +0100
Re: [PATCH] usb: interface: allow drivers declare number of endpoints they need Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2015-12-01 02:10 +0100
Re: [PATCH] usb: interface: allow drivers declare number of endpoints they need Oliver Neukum <oneukum@suse.com> - 2015-12-01 09:00 +0100
Re: [PATCH] usb: interface: allow drivers declare number of endpoints they need Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2015-12-01 18:10 +0100
Re: [PATCH] usb: interface: allow drivers declare number of endpoints they need Josh Boyer <jwboyer@fedoraproject.org> - 2015-12-01 20:50 +0100
Re: [PATCH] usb: interface: allow drivers declare number of endpoints they need Dmitry Torokhov <dmitry.torokhov@gmail.com> - 2015-12-01 20:50 +0100
csiph-web