aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorJohan Hovold <johan@kernel.org>2017-03-14 12:55:45 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-03-30 03:41:24 -0400
commit73c4e2ede5a999d8b48c6be8614aeeb7abbba90f (patch)
tree3bfba00d8cd4a32797bdefefb4ee20b2ae590168 /drivers/usb
parent4e615886770a0815412a4b3c2aa4b83b9ac3ad6a (diff)
USB: usbtmc: add missing endpoint sanity check
commit 687e0687f71ec00e0132a21fef802dee88c2f1ad upstream. USBTMC devices are required to have a bulk-in and a bulk-out endpoint, but the driver failed to verify this, something which could lead to the endpoint addresses being taken from uninitialised memory. Make sure to zero all private data as part of allocation, and add the missing endpoint sanity check. Note that this also addresses a more recently introduced issue, where the interrupt-in-presence flag would also be uninitialised whenever the optional interrupt-in endpoint is not present. This in turn could lead to an interrupt urb being allocated, initialised and submitted based on uninitialised values. Fixes: dbf3e7f654c0 ("Implement an ioctl to support the USMTMC-USB488 READ_STATUS_BYTE operation.") Fixes: 5b775f672cc9 ("USB: add USB test and measurement class driver") Signed-off-by: Johan Hovold <johan@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/class/usbtmc.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/drivers/usb/class/usbtmc.c b/drivers/usb/class/usbtmc.c
index a6c1fae7d52a..512afa5da00f 100644
--- a/drivers/usb/class/usbtmc.c
+++ b/drivers/usb/class/usbtmc.c
@@ -1380,7 +1380,7 @@ static int usbtmc_probe(struct usb_interface *intf,
1380 1380
1381 dev_dbg(&intf->dev, "%s called\n", __func__); 1381 dev_dbg(&intf->dev, "%s called\n", __func__);
1382 1382
1383 data = kmalloc(sizeof(*data), GFP_KERNEL); 1383 data = kzalloc(sizeof(*data), GFP_KERNEL);
1384 if (!data) 1384 if (!data)
1385 return -ENOMEM; 1385 return -ENOMEM;
1386 1386
@@ -1443,6 +1443,13 @@ static int usbtmc_probe(struct usb_interface *intf,
1443 break; 1443 break;
1444 } 1444 }
1445 } 1445 }
1446
1447 if (!data->bulk_out || !data->bulk_in) {
1448 dev_err(&intf->dev, "bulk endpoints not found\n");
1449 retcode = -ENODEV;
1450 goto err_put;
1451 }
1452
1446 /* Find int endpoint */ 1453 /* Find int endpoint */
1447 for (n = 0; n < iface_desc->desc.bNumEndpoints; n++) { 1454 for (n = 0; n < iface_desc->desc.bNumEndpoints; n++) {
1448 endpoint = &iface_desc->endpoint[n].desc; 1455 endpoint = &iface_desc->endpoint[n].desc;
@@ -1511,6 +1518,7 @@ error_register:
1511 sysfs_remove_group(&intf->dev.kobj, &capability_attr_grp); 1518 sysfs_remove_group(&intf->dev.kobj, &capability_attr_grp);
1512 sysfs_remove_group(&intf->dev.kobj, &data_attr_grp); 1519 sysfs_remove_group(&intf->dev.kobj, &data_attr_grp);
1513 usbtmc_free_int(data); 1520 usbtmc_free_int(data);
1521err_put:
1514 kref_put(&data->kref, usbtmc_delete); 1522 kref_put(&data->kref, usbtmc_delete);
1515 return retcode; 1523 return retcode;
1516} 1524}