Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754838AbbK3Vj5 (ORCPT ); Mon, 30 Nov 2015 16:39:57 -0500 Received: from arroyo.ext.ti.com ([192.94.94.40]:34252 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752861AbbK3Vjz (ORCPT ); Mon, 30 Nov 2015 16:39:55 -0500 From: Felipe Balbi To: Dmitry Torokhov , Greg Kroah-Hartman CC: Alan Stern , Vladis Dronov , , Subject: Re: [PATCH] usb: interface: allow drivers declare number of endpoints they need In-Reply-To: <20151130211150.GA38770@dtor-ws> References: <20151130211150.GA38770@dtor-ws> User-Agent: Notmuch/0.21 (http://notmuchmail.org) Emacs/24.5.1 (x86_64-pc-linux-gnu) Date: Mon, 30 Nov 2015 15:39:43 -0600 Message-ID: <87y4df180w.fsf@saruman.tx.rr.com> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2907 Lines: 77 --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Hi, Dmitry Torokhov 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 > Signed-off-by: Dmitry Torokhov > --- > > 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) >=20=20 > dev_dbg(dev, "%s - got id\n", __func__); >=20=20 > + 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. =2D-=20 balbi --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJWXMIiAAoJEIaOsuA1yqREtf0P/3NdPXQKHUzXOpbToCpfUwJo bVWTXv6/Vu9hjdinutosi9FMNVXEWPt0tuFn2F9oipshmLGbAFRrCHd9xg5i99nf 9v3uWMd6qemnhlL16GVBct+vQSS1TZauZd8yri9TbsRJ/hA4yFe3cu3NeKJ6S/ju QKD3+uGPUDog6U7QHMFLaaYN89b/RQ3jp0QY81JC2wO03bNyBmBawV3x9ZI27v3h hcRwTkcwR6FGQfzFlvbeVWcrBbxpJOHPmau1naBBFmw/j+IuCdrcujnTXTb3I9Vb CTKdWDx7s0MkoaZAH0Viz+oPlJaz64/ieukE0pjMbdqXaLThj7Kh+KkzC5OoStNK LR6jacmE+46Dm0hrYMdgyWNYKF8bemTdhKM02Lnjohy+FVkvWevkD6Y519tGZqZw R8vwoYGiFogaxZpEsX4Sd5kufnCSV/07xQD8wuWbmy2UhW5JfBjS0NQXdPIX4qEV Pgp06eIzPxTGr8QL35od2hVhtbPY2fQTFliRh8JTGkOvyjAMoIUhHxAOdWWDI0IY 6T4r6L9IUMZFB16RFJLxby78cZV/zHln+X/PsKio/XuX7SLJgQ2ZMGEvNFG4kgr3 V6t2oiEr3IG6tE/LsbRJIdBJk2kewGr3vtuHoZUCA1YkzhoxYejKYS6Z1iV3tE3X C0IalTF/VYC+DPcv1F05 =Azb0 -----END PGP SIGNATURE----- --=-=-=-- -- 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/