Thread (10 messages) flat view 10 messages, 2 authors, 2021-03-23
STALE1964d LANDED: 3 (3M)

Revision v2 of 2 in this series; 1 review trailer (1 from subsystem maintainers); landed in mainline as 4e49bf376c04 on 2021-03-23.

Revisions (2)
  1. v1 [diff vs current]
  2. v2 current

[PATCH v2 2/8] USB: cdc-acm: fix use-after-free after probe failure

From: Johan Hovold <johan@kernel.org>
Date: 2021-03-22 15:53:52
Also in: lkml, stable
Subsystem: the rest, usb acm driver, usb subsystem · Maintainers: Linus Torvalds, Oliver Neukum, Greg Kroah-Hartman

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: stable@vger.kernel.org      # 3.9
Cc: Alexey Khoroshilov <redacted>
Acked-by: Oliver Neukum <oneukum@suse.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/usb/class/cdc-acm.c | 5 +++++
 1 file changed, 5 insertions(+)
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index d75a78ad464d..dfc2480add91 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -1503,6 +1503,11 @@ static int acm_probe(struct usb_interface *intf,
 
 	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);
-- 
2.26.3
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help