aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/class/cdc-acm.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/class/cdc-acm.c')
-rw-r--r--drivers/usb/class/cdc-acm.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index 8ac25adf31b4..387dc6c8ad25 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -593,7 +593,6 @@ static void acm_port_destruct(struct tty_port *port)
593 593
594 dev_dbg(&acm->control->dev, "%s\n", __func__); 594 dev_dbg(&acm->control->dev, "%s\n", __func__);
595 595
596 tty_unregister_device(acm_tty_driver, acm->minor);
597 acm_release_minor(acm); 596 acm_release_minor(acm);
598 usb_put_intf(acm->control); 597 usb_put_intf(acm->control);
599 kfree(acm->country_codes); 598 kfree(acm->country_codes);
@@ -977,6 +976,8 @@ static int acm_probe(struct usb_interface *intf,
977 int num_rx_buf; 976 int num_rx_buf;
978 int i; 977 int i;
979 int combined_interfaces = 0; 978 int combined_interfaces = 0;
979 struct device *tty_dev;
980 int rv = -ENOMEM;
980 981
981 /* normal quirks */ 982 /* normal quirks */
982 quirks = (unsigned long)id->driver_info; 983 quirks = (unsigned long)id->driver_info;
@@ -1339,11 +1340,24 @@ skip_countries:
1339 usb_set_intfdata(data_interface, acm); 1340 usb_set_intfdata(data_interface, acm);
1340 1341
1341 usb_get_intf(control_interface); 1342 usb_get_intf(control_interface);
1342 tty_port_register_device(&acm->port, acm_tty_driver, minor, 1343 tty_dev = tty_port_register_device(&acm->port, acm_tty_driver, minor,
1343 &control_interface->dev); 1344 &control_interface->dev);
1345 if (IS_ERR(tty_dev)) {
1346 rv = PTR_ERR(tty_dev);
1347 goto alloc_fail8;
1348 }
1344 1349
1345 return 0; 1350 return 0;
1351alloc_fail8:
1352 if (acm->country_codes) {
1353 device_remove_file(&acm->control->dev,
1354 &dev_attr_wCountryCodes);
1355 device_remove_file(&acm->control->dev,
1356 &dev_attr_iCountryCodeRelDate);
1357 }
1358 device_remove_file(&acm->control->dev, &dev_attr_bmCapabilities);
1346alloc_fail7: 1359alloc_fail7:
1360 usb_set_intfdata(intf, NULL);
1347 for (i = 0; i < ACM_NW; i++) 1361 for (i = 0; i < ACM_NW; i++)
1348 usb_free_urb(acm->wb[i].urb); 1362 usb_free_urb(acm->wb[i].urb);
1349alloc_fail6: 1363alloc_fail6:
@@ -1359,7 +1373,7 @@ alloc_fail2:
1359 acm_release_minor(acm); 1373 acm_release_minor(acm);
1360 kfree(acm); 1374 kfree(acm);
1361alloc_fail: 1375alloc_fail:
1362 return -ENOMEM; 1376 return rv;
1363} 1377}
1364 1378
1365static void stop_data_traffic(struct acm *acm) 1379static void stop_data_traffic(struct acm *acm)
@@ -1411,6 +1425,8 @@ static void acm_disconnect(struct usb_interface *intf)
1411 1425
1412 stop_data_traffic(acm); 1426 stop_data_traffic(acm);
1413 1427
1428 tty_unregister_device(acm_tty_driver, acm->minor);
1429
1414 usb_free_urb(acm->ctrlurb); 1430 usb_free_urb(acm->ctrlurb);
1415 for (i = 0; i < ACM_NW; i++) 1431 for (i = 0; i < ACM_NW; i++)
1416 usb_free_urb(acm->wb[i].urb); 1432 usb_free_urb(acm->wb[i].urb);