Skip to contentSkip to conversation

usbtmc: more sanity checking for packet size

PATCH New Oliver Neukum 1 participant 1 message Aug 20, 2019 USB

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usbtmc: more sanity checking for packet size

A malicious device can make the driver divide ny zero with a nonsense maximum packet size.

V2: return a sensible error code

---
 drivers/usb/class/usbtmc.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/usb/class/usbtmc.c +3 -0
index 4942122b2346..36858ddd8d9b 100644
@@ -2362,8 +2362,11 @@ static int usbtmc_probe(struct usb_interface *intf,
 		goto err_put;
 	}
 
+	retcode = -EINVAL;
 	data->bulk_in = bulk_in->bEndpointAddress;
 	data->wMaxPacketSize = usb_endpoint_maxp(bulk_in);
+	if (!data->wMaxPacketSize)
+		goto err_put;
 	dev_dbg(&intf->dev, "Found bulk in endpoint at %u\n", data->bulk_in);
 
 	data->bulk_out = bulk_out->bEndpointAddress;
Signature · 1 line
2.16.4