Skip to contentSkip to conversation

CDC-ACM: fix poison/unpoison imbalance

PATCH In review Oliver Neukum 2 participants 2 messages Apr 21, 2021 – Apr 22, 2021

Subsystems (2)
lore
Share & tools
lore

Oliver Neukum

author maintainer
#0 lore raw

PATCH 1/1 CDC-ACM: fix poison/unpoison imbalance

suspend() does its poisoning conditionally, resume() does it unconditionally. On a device with combined interfaces this will balance, on a device with two interfaces the counter will go negative and resubmission will fail.

Both actions need to be done conditionally.

Fixes 6069e3e927c8f ("USB: cdc-acm: untangle a circular dependency between callback and softint")
---
 drivers/usb/class/cdc-acm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/class/cdc-acm.c +2 -1
index 3fda1ec961d7..f5886c512fec 100644
@@ -1634,12 +1634,13 @@ static int acm_resume(struct usb_interface *intf)
 	struct urb *urb;
 	int rv = 0;
 
-	acm_unpoison_urbs(acm);
 	spin_lock_irq(&acm->write_lock);
 
 	if (--acm->susp_count)
 		goto out;
 
+	acm_unpoison_urbs(acm);
+
 	if (tty_port_initialized(&acm->port)) {
 		rv = usb_submit_urb(acm->ctrlurb, GFP_ATOMIC);
 
Signature · 1 line
2.26.2
Tested-by on v1 1/1
#1 lore raw
Quoted 6 lines · Oliver Neukum

suspend() does its poisoning conditionally, resume() does it unconditionally. On a device with combined interfaces this will balance, on a device with two interfaces the counter will go negative and resubmission will fail.

Both actions need to be done conditionally.

FWIW, this relates to the issue reported on the kernel bugzilla:
https://bugzilla.kernel.org/show_bug.cgi?id=212725

Thanks for addressing this!

Quoted 4 lines
Fixes 6069e3e927c8f ("USB: cdc-acm: untangle a circular dependency

between callback and softint")

--
Stefan

Quoted 22 lines
---
 drivers/usb/class/cdc-acm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/class/cdc-acm.c +2 -1
index 3fda1ec961d7..f5886c512fec 100644
@@ -1634,12 +1634,13 @@ static int acm_resume(struct usb_interface *intf)
 	struct urb *urb;
 	int rv = 0;
 
-	acm_unpoison_urbs(acm);
 	spin_lock_irq(&acm->write_lock);
 
 	if (--acm->susp_count)
 		goto out;
 
+	acm_unpoison_urbs(acm);
+
 	if (tty_port_initialized(&acm->port)) {
 		rv = usb_submit_urb(acm->ctrlurb, GFP_ATOMIC);