From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Felipe Balbi <balbi@ti.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Alan Stern <stern@rowland.harvard.edu>,
Vladis Dronov <vdronov@redhat.com>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] usb: interface: allow drivers declare number of endpoints they need
Date: Mon, 30 Nov 2015 14:20:34 -0800 [thread overview]
Message-ID: <20151130222034.GA20749@dtor-ws> (raw)
In-Reply-To: <87y4df180w.fsf@saruman.tx.rr.com>
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
next prev parent reply other threads:[~2015-11-30 22:20 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-30 21:11 [PATCH] usb: interface: allow drivers declare number of endpoints they need Dmitry Torokhov
2015-11-30 21:39 ` Felipe Balbi
2015-11-30 22:20 ` Dmitry Torokhov [this message]
2015-11-30 22:18 ` Greg Kroah-Hartman
2015-11-30 22:56 ` Dmitry Torokhov
2015-11-30 23:36 ` Greg Kroah-Hartman
2015-12-01 0:47 ` Dmitry Torokhov
2015-12-01 1:09 ` Greg Kroah-Hartman
2015-12-01 7:53 ` Oliver Neukum
2015-12-01 17:07 ` Greg Kroah-Hartman
2015-12-01 19:46 ` Josh Boyer
2015-12-01 19:47 ` Dmitry Torokhov
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=20151130222034.GA20749@dtor-ws \
--to=dmitry.torokhov@gmail.com \
--cc=balbi@ti.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=stern@rowland.harvard.edu \
--cc=vdronov@redhat.com \
/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