aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohan Hovold <[email protected]>2021-03-22 16:53:12 +0100
committerGreg Kroah-Hartman <[email protected]>2021-03-23 13:27:13 +0100
commit4e49bf376c0451ad2eae2592e093659cde12be9a (patch)
tree138b949de9f4417136cf34d5d253a52cb4a12b06
parent7180495cb3d0e2a2860d282a468b4146c21da78f (diff)
USB: cdc-acm: fix use-after-free after probe failure
If tty-device registration fails the driver would fail to release the data interface. When the device is later disconnected, the disconnect callback would still be called for the data interface and would go about releasing already freed resources. Fixes: c93d81955005 ("usb: cdc-acm: fix error handling in acm_probe()") Cc: [email protected] # 3.9 Cc: Alexey Khoroshilov <[email protected]> Acked-by: Oliver Neukum <[email protected]> Signed-off-by: Johan Hovold <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
-rw-r--r--drivers/usb/class/cdc-acm.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index d5fbb943c4c1..6decf8f2b9ae 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -1516,6 +1516,11 @@ skip_countries:
return 0;
alloc_fail6:
+ if (!acm->combined_interfaces) {
+ /* Clear driver data so that disconnect() returns early. */
+ usb_set_intfdata(data_interface, NULL);
+ usb_driver_release_interface(&acm_driver, data_interface);
+ }
if (acm->country_codes) {
device_remove_file(&acm->control->dev,
&dev_attr_wCountryCodes);