linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net,stable] usbnet: ignore endpoints with invalid wMaxPacketSize
@ 2019-09-18 12:17 Bjørn Mork
  2019-09-21  2:03 ` Jakub Kicinski
  0 siblings, 1 reply; 4+ messages in thread
From: Bjørn Mork @ 2019-09-18 12:17 UTC (permalink / raw)
  To: netdev; +Cc: linux-usb, Oliver Neukum, Bjørn Mork

Endpoints with zero wMaxPacketSize are not usable for transferring
data. Ignore such endpoints when looking for valid in, out and
status pipes, to make the drivers more robust against invalid and
meaningless descriptors.

The wMaxPacketSize of these endpoints are used for memory allocations
and as divisors in many usbnet minidrivers. Avoiding zero is therefore
critical.

Signed-off-by: Bjørn Mork <bjorn@mork.no>
---
 drivers/net/usb/usbnet.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index 58952a79b05f..dbea2136d901 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -100,6 +100,11 @@ int usbnet_get_endpoints(struct usbnet *dev, struct usb_interface *intf)
 			int				intr = 0;
 
 			e = alt->endpoint + ep;
+
+			/* ignore endpoints which cannot transfer data */
+			if (!usb_endpoint_maxp(&e->desc))
+				continue;
+
 			switch (e->desc.bmAttributes) {
 			case USB_ENDPOINT_XFER_INT:
 				if (!usb_endpoint_dir_in(&e->desc))
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-09-21 19:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-18 12:17 [PATCH net,stable] usbnet: ignore endpoints with invalid wMaxPacketSize Bjørn Mork
2019-09-21  2:03 ` Jakub Kicinski
2019-09-21 12:54   ` Bjørn Mork
2019-09-21 19:30     ` Jakub Kicinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).